我正在使用Sapphire on Steel上的Visual Basic添加語言Ruby來編譯和運行我的代碼。我正在爲一個學校項目製作一個二十一點計劃,無論出於什麼原因,我無法準確地找到擺脫我創建的循環的方式。 Loop將繼續運行代碼,詢問用戶他們是否要點擊或站立,並根據用戶輸入的信息來判斷他們是否繼續點擊或結束。任何和所有的意見,將不勝感激。感謝您的時間。我被困在我的循環中,我該如何退出?
while choice != "stand"
#This is the loop that I can not find my way out of
while choice != "hit" || choice != "stand"
puts "Would you like to hit or stand?"
choice = gets.chomp!
choice.downcase
if choice == "hit"
puts "You have chosen to hit \n\n"
player.drawCard(myDeck)
puts "Player's Hand: \n"
player.showHand()
puts "\n"
puts "Player Score: \n"
player.determineScore()
puts player.printScore()
puts "\n \n"
elsif choice == "stand"
puts "You have chosen to stand \n\n"
puts "Player's Hand: \n"
player.showHand()
puts "\n"
puts "Player Score: \n"
player.determineScore()
puts player.printScore()
puts "\n \n"
else
puts "Your choice is not acceptable please choose again"
end
end
使用'&&'代替'||'。 – JJJ