루비에서 슬롯 머신 게임을 만들고 싶습니다. 그리고 지금까지 제가 얻은 것입니다. 여전히 실행되지 않으며 마지막 줄에 오류가 있으며 어떤 점이 무엇인지 또는 어떻게 수정해야하는지 모릅니다. ,루비 슬롯 머신 게임 프로그래밍하기
How much total money would you like to play with today? 25
Total cash: $ 25
How much would you like to bet? 10
Cherry - Orange - Orange
You have won $ 20
Would you like to continue? (yes to continue) yes
Total cash: $ 35
How much would you like to bet? etc…
이미 상금은 두를 얻을 경우, 당신은 두 번 내기를 이길처럼, 거기에 설정하고 세를 얻는 경우에있어했습니다
나는 다음과 유사한 출력을 가질 필요 너는 너의 내기의 3 시간을 이긴다.
하지만 오류 얻을 : 33: syntax error, unexpected $end, expecting kEND cash += cash + winnings
무엇 내 코드에 문제가 있습니다, 내가 그것을 어떻게 해결합니까를?
def multiplier(s1, s2, s3)
if s1 == s2 and s2 == s3:
multiplier = 3
elsif s1 == s2 or s2 == s3 or s1 == s3:
multiplier = 2
else
multiplier = 0;
return multiplier
def main()
slotImageList = ['Cherry', 'Orange', 'Plum', 'Bell', 'Melon', 'Bar']
cash = gets
puts "How much total money would you like to play with today? " +cash
while True:
puts("Total cash: $", cash)
bet = gets
puts "How much would you like to bet? " +bet
cash = (cash - bet)
slotImage1 = slotImageList.sample
slotImage2 = slotImageList.sample
slotImage3 = slotImageList.sample
puts "slotImage1", " - ", "slotImage2", " - ", "slotImage3"
winnings = bet * multiplier(slotImage1, slotImage2, slotImage3)
puts "You have won $" +winnings
cash = cash + winnings
cont = gets
puts "Would you like to continue? (yes to continue) " +cont
if cont != "yes":
puts "You have ended with $" +cash
else
puts " "
end
구체적으로 어떤 오류 메시지가 나타 납니까? 33 : – sarnold
@sarnold는, 이것은 내가 나타나는 오류 메시지입니다 구문 오류, 예기치 못한 $ 끝, kEND 현금 + = 현금 + 위닝 ^ – user1368970
실행하고 있기 때문에 글쎄, 당신은 오류 메시지를 받고있어 뭔가를 기대하는 파이썬처럼 루비 인터프리터로 포맷됩니다. –