I am a newbie in Ruby. I am trying to write a simple interactive game in ruby but am stuck. Need help to proceed. Below is the concept:
money = [100, 200, 300, 400]
beneficiaries = ["John", "Sam", "Mary"]
cost1 = [50, 25, 30, 75, 18]
cost2 = [120, 150, 200, 250]
gift1 = [" crayon ", " Pencil ", " Biro "]
gift2 = [" bag ", " shoe ", " Radio "]
cashowned = [50]
a = money.sample
b = cost1.sample
c = cost2.sample
d = gift1.sample
e = gift2.sample
f = cashowned
puts " Hi, what is your name? "
puts
name = gets.chomp
puts
puts " #{name} is a nice name."
puts
puts "#{name} you have #{f} in your bank account."
puts
puts "Roll the dice and let's see how much you just earned."
puts
gets.chomp.to_i
dice1 = a
puts "#{name} you just earned: #{dice1}"
puts
gets.chomp.to_i
Cashowned = dice1 + f
puts "Your account balance is now : #{cashowned}"
puts
gets.chomp.to_i
I am stuck here. I want to repeat/loop the sequence so that I can give out gift at a cost and deduct from cash owned. But cash owned is not updating. A simpler way to go about this will be appreciated. Thanks.
