Rubyでスロットマシンゲームを作ろうとしていますが、これは私が得た限りです. それでも実行されず、最後の行にエラーがあると表示されますが、エラーの内容や修正方法がわかりません。
次のような出力が必要です。
今日の合計金額はいくらですか? 25
合計現金: $ 25
いくら賭けますか? 10
チェリー - オレンジ - オレンジ
$20 を獲得し
ました 続行しますか? (続行する場合ははい) はい
合計現金: $ 35
いくら賭けますか? など…</p>
私はすでにそこに賞金を設定しています.2つを獲得すると、賭け金の2倍を獲得し、3つを獲得すると、賭け金の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