Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它. 我需要它有一个类似于这样的输出: How much total money would you like to play with today? 25 Total cash: $25 How much would you like to bet? 10 Cherry – O 我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它.

我需要它有一个类似于这样的输出:

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…

我已经在那里设置了奖金,就像你拿到两个,你赢了两次你的赌注,如果你赢了三个,你赢了三次你的赌注.

但我得到错误:33:语法错误,意外的$end,期待kEND现金=现金奖金

我的代码有什么问题,我该如何解决?

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
解决方法 当您看到消息时:

unexpected $end,expecting kEND

你可以将它翻译成“我到达文件结尾(”$end“),但我没想到,因为我还在等待结束语.”这意味着您忘记键入至少一个配对的末尾,并且您需要检查代码并确保它正确缩进,以便您可以直观地匹配语句.

以下是修复代码正确的结果.在某些地方你似乎使用缩进来关闭一个块(比如Python)而不是正确的语法.

def multiplIEr(s1,s3)  if s1==s2 && s2==s3    3  elsif s1==s2 || s2==s3 || s1==s3    2  else    0  endenddef run_slots!  slotimageList = %w[Cherry Orange Plum Bell Melon bar]  print "How much total money would you like to play with today? "  cash = gets.chomp.to_i  loop do    puts "Total cash:  $#{cash}"    print "How much would you like to bet? "    bet = gets.chomp.to_i    cash -= bet    slotimage1 = slotimageList.sample    slotimage2 = slotimageList.sample    slotimage3 = slotimageList.sample    puts "#{slotimage1} - #{slotimage2} - #{slotimage3}"    winnings = bet * multiplIEr(slotimage1,slotimage3)    puts "You have won $#{winnings}"    cash += winnings    print "Would you like to continue? (yes to continue) "    unless gets.chomp=="yes"      puts "You have ended with $#{cash}"      break    end  endendrun_slots! if __file__==
class SlotGame  SLOT_COUNT = 3  TOKENS     = %w[Cherry Orange Plum Bell Melon bar]  KEEP_PLAYING_RESPONSES = %w[y yes sure ok go]  def initialize(cash=nil)    unless cash      begin        print "How much total money would you like to play with today? "        cash = gets.to_i        puts "You must have a positive bank account to play!" if cash<=0      end until cash > 0    end    @cash = cash  end  def play_forever    begin      # Using begin/end ensures one turn will be played      # before asking the player if they want to go on      play_one_turn    end while @cash>0 && keep_playing?    puts "You have ended with $#{@cash}; goodbye!"  end  def play_one_turn    puts "Total cash: $#{@cash}"    begin      print "How much would you like to bet? "      bet = gets.to_i      puts "You only have $#{@cash}!" if bet > @cash    end until bet <= @cash    @cash -= bet    results = SLOT_COUNT.times.map{ TOKENS.sample }    puts results.join(' - ')    winnings = bet * multiplIEr(results)    if winnings>0      @cash += winnings      puts "You just won $#{winnings}!"    else      puts "Sorry,you're not a winner."    end  end  def keep_playing?    print "Would you like to continue? "    KEEP_PLAYING_RESPONSES.include?(gets.chomp.downcase)  end  private # Don't let anyone outsIDe run our magic formula!    def multiplIEr(*tokens)      case tokens.flatten.uniq.length        when 1 then 3        when 2 then 2        else 0      end    endendSlotGame.new.play_forever if __file__==[+++]

如果我对它采取更多的自由,这就是我可以写它的方式:

[+++] 总结

以上是内存溢出为你收集整理的编程Ruby老虎机游戏全部内容,希望文章能够帮你解决编程Ruby老虎机游戏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它. 我需要它有一个类似于这样的输出: How much total money would you like to play with today? 25 Total cash: $25 How much would you like to bet? 10 Cherry – O 我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它.

我需要它有一个类似于这样的输出:

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…

我已经在那里设置了奖金,就像你拿到两个,你赢了两次你的赌注,如果你赢了三个,你赢了三次你的赌注.

但我得到错误:33:语法错误,意外的$end,期待kEND现金=现金奖金

我的代码有什么问题,我该如何解决?

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
解决方法 当您看到消息时:

unexpected $end,expecting kEND

你可以将它翻译成“我到达文件结尾(”$end“),但我没想到,因为我还在等待结束语.”这意味着您忘记键入至少一个配对的末尾,并且您需要检查代码并确保它正确缩进,以便您可以直观地匹配语句.

以下是修复代码正确的结果.在某些地方你似乎使用缩进来关闭一个块(比如Python)而不是正确的语法.

def multiplIEr(s1,s3)  if s1==s2 && s2==s3    3  elsif s1==s2 || s2==s3 || s1==s3    2  else    0  endenddef run_slots!  slotimageList = %w[Cherry Orange Plum Bell Melon bar]  print "How much total money would you like to play with today? "  cash = gets.chomp.to_i  loop do    puts "Total cash:  $#{cash}"    print "How much would you like to bet? "    bet = gets.chomp.to_i    cash -= bet    slotimage1 = slotimageList.sample    slotimage2 = slotimageList.sample    slotimage3 = slotimageList.sample    puts "#{slotimage1} - #{slotimage2} - #{slotimage3}"    winnings = bet * multiplIEr(slotimage1,slotimage3)    puts "You have won $#{winnings}"    cash += winnings    print "Would you like to continue? (yes to continue) "    unless gets.chomp=="yes"      puts "You have ended with $#{cash}"      break    end  endendrun_slots! if __file__==
class SlotGame  SLOT_COUNT = 3  TOKENS     = %w[Cherry Orange Plum Bell Melon bar]  KEEP_PLAYING_RESPONSES = %w[y yes sure ok go]  def initialize(cash=nil)    unless cash      begin        print "How much total money would you like to play with today? "        cash = gets.to_i        puts "You must have a positive bank account to play!" if cash<=0      end until cash > 0    end    @cash = cash  end  def play_forever    begin      # Using begin/end ensures one turn will be played      # before asking the player if they want to go on      play_one_turn    end while @cash>0 && keep_playing?    puts "You have ended with $#{@cash}; goodbye!"  end  def play_one_turn    puts "Total cash: $#{@cash}"    begin      print "How much would you like to bet? "      bet = gets.to_i      puts "You only have $#{@cash}!" if bet > @cash    end until bet <= @cash    @cash -= bet    results = SLOT_COUNT.times.map{ TOKENS.sample }    puts results.join(' - ')    winnings = bet * multiplIEr(results)    if winnings>0      @cash += winnings      puts "You just won $#{winnings}!"    else      puts "Sorry,you're not a winner."    end  end  def keep_playing?    print "Would you like to continue? "    KEEP_PLAYING_RESPONSES.include?(gets.chomp.downcase)  end  private # Don't let anyone outsIDe run our magic formula!    def multiplIEr(*tokens)      case tokens.flatten.uniq.length        when 1 then 3        when 2 then 2        else 0      end    endendSlotGame.new.play_forever if __file__==

如果我对它采取更多的自由,这就是我可以写它的方式:

[+++] 总结

以上是内存溢出为你收集整理的编程Ruby老虎机游戏全部内容,希望文章能够帮你解决编程Ruby老虎机游戏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
编程Ruby老虎机游戏_语言综合_内存溢出

编程Ruby老虎机游戏

编程Ruby老虎机游戏,第1张

概述我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它. 我需要它有一个类似于这样的输出: How much total money would you like to play with today? 25 Total cash: $25 How much would you like to bet? 10 Cherry – O 我正在尝试用 Ruby创建一个老虎机游戏,这是我已经得到的.它仍然无法运行,并说最后一行有错误,我不知道是什么或如何解决它.

我需要它有一个类似于这样的输出:

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…

我已经在那里设置了奖金,就像你拿到两个,你赢了两次你的赌注,如果你赢了三个,你赢了三次你的赌注.

但我得到错误:33:语法错误,意外的$end,期待kEND现金=现金奖金

我的代码有什么问题,我该如何解决?

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
解决方法 当您看到消息时:

unexpected $end,expecting kEND

你可以将它翻译成“我到达文件结尾(”$end“),但我没想到,因为我还在等待结束语.”这意味着您忘记键入至少一个配对的末尾,并且您需要检查代码并确保它正确缩进,以便您可以直观地匹配语句.

以下是修复代码正确的结果.在某些地方你似乎使用缩进来关闭一个块(比如Python)而不是正确的语法.

def multiplIEr(s1,s3)  if s1==s2 && s2==s3    3  elsif s1==s2 || s2==s3 || s1==s3    2  else    0  endenddef run_slots!  slotimageList = %w[Cherry Orange Plum Bell Melon bar]  print "How much total money would you like to play with today? "  cash = gets.chomp.to_i  loop do    puts "Total cash:  $#{cash}"    print "How much would you like to bet? "    bet = gets.chomp.to_i    cash -= bet    slotimage1 = slotimageList.sample    slotimage2 = slotimageList.sample    slotimage3 = slotimageList.sample    puts "#{slotimage1} - #{slotimage2} - #{slotimage3}"    winnings = bet * multiplIEr(slotimage1,slotimage3)    puts "You have won $#{winnings}"    cash += winnings    print "Would you like to continue? (yes to continue) "    unless gets.chomp=="yes"      puts "You have ended with $#{cash}"      break    end  endendrun_slots! if __file__==
class SlotGame  SLOT_COUNT = 3  TOKENS     = %w[Cherry Orange Plum Bell Melon bar]  KEEP_PLAYING_RESPONSES = %w[y yes sure ok go]  def initialize(cash=nil)    unless cash      begin        print "How much total money would you like to play with today? "        cash = gets.to_i        puts "You must have a positive bank account to play!" if cash<=0      end until cash > 0    end    @cash = cash  end  def play_forever    begin      # Using begin/end ensures one turn will be played      # before asking the player if they want to go on      play_one_turn    end while @cash>0 && keep_playing?    puts "You have ended with $#{@cash}; goodbye!"  end  def play_one_turn    puts "Total cash: $#{@cash}"    begin      print "How much would you like to bet? "      bet = gets.to_i      puts "You only have $#{@cash}!" if bet > @cash    end until bet <= @cash    @cash -= bet    results = SLOT_COUNT.times.map{ TOKENS.sample }    puts results.join(' - ')    winnings = bet * multiplIEr(results)    if winnings>0      @cash += winnings      puts "You just won $#{winnings}!"    else      puts "Sorry,you're not a winner."    end  end  def keep_playing?    print "Would you like to continue? "    KEEP_PLAYING_RESPONSES.include?(gets.chomp.downcase)  end  private # Don't let anyone outsIDe run our magic formula!    def multiplIEr(*tokens)      case tokens.flatten.uniq.length        when 1 then 3        when 2 then 2        else 0      end    endendSlotGame.new.play_forever if __file__==

如果我对它采取更多的自由,这就是我可以写它的方式:

总结

以上是内存溢出为你收集整理的编程Ruby老虎机游戏全部内容,希望文章能够帮你解决编程Ruby老虎机游戏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1274251.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存