Hi,
I was having some trouble with my code for a Craps game. The Code is pretty elementary, we don't have to do any betting. I don't understand two things:
1. How to have 2 whiles
ex. while point != 5 *and* while point !=6
2. Why my code won't work. I tried removing the second while statement and it still didn't work. Any ideas?
CODE
puts "Welcome to Craps"
roll1 = 2 + rand(6) + rand(6)
if roll1 == 7
puts "Your roll is " + roll1.to_s + ". You win!"
if roll1 == 11
puts "Your roll is " + roll1.to_s + ". You win!"
if roll1 == 2
puts "Your roll is " + roll1.to_s + ". You lose!"
if roll1 == 3
puts "Your roll is " + roll1.to_s + ". You lose!"
if roll1 == 12
puts "Your roll is " + roll1.to_s + ". You win!"
else
puts "Your roll was " + roll1.to_s + ". Roll again!"
point = 2 + rand(6) + rand(6)
if point == 7
puts "Your roll is " + point.to_s + ". You lose!"
if point == roll1
puts "Point is " + point.to_s + ". You win!"
while point != roll1, 7 do
puts "Your roll is " + point.to_s + ". Roll again!"
roll2 = 2 + rand(6) + rand(6)
if roll2 == 7
puts "Your roll is " + point.to_s + ". You lose!"
if roll2 == roll1
puts "Point is " + point.to_s + ". You win!"
end