for quite a while, on and off, and it's not going so well.
Anyways, I'm trying to learn ruby, currently using some really new version of it. my editor is scite, cause i really like how it looks.
and anyways, I just have a bunch of really small problems that I figured i can just post up here. I'm quite sure they are amazingly noob, and googling it is hard because it's like something i feel everyone should already know so...
whatev.
anyways, when using "x .. y", with x and y as two different numbers, it means the numbers between x and y, right? just checking
anyways, im trying to develop a small game where a random number is generated from 0 to 100, and you have seven chances to get the correct number.
im messing up somewhere. it repeats at the first while control part, and the error the scite is saying is that there's a "warning: integer literal in conditional range"
anyways can anyone check it for me? probably be posting my other futile attempts later as well
Anyways, I'm trying to learn ruby, currently using some really new version of it. my editor is scite, cause i really like how it looks.
and anyways, I just have a bunch of really small problems that I figured i can just post up here. I'm quite sure they are amazingly noob, and googling it is hard because it's like something i feel everyone should already know so...
whatev.
anyways, when using "x .. y", with x and y as two different numbers, it means the numbers between x and y, right? just checking
anyways, im trying to develop a small game where a random number is generated from 0 to 100, and you have seven chances to get the correct number.
im messing up somewhere. it repeats at the first while control part, and the error the scite is saying is that there's a "warning: integer literal in conditional range"
anyways can anyone check it for me? probably be posting my other futile attempts later as well
Code:
number = rand(101)
x = 0
count = 0
puts "Input a number from 0 to 100."
puts "You have seven chances."
x = gets.chomp
while x != 1 .. 100
puts "Please input a number from 0 to 100."
x = gets.chomp
if x == 1 .. 100
break
end
end
end
while count < 7
if x >= number
puts x.to_s + " is too high!"
count = count + 1
if count == 6
puts "You have 1 chance left."
else puts "You have " + count.to_s + " chances left."
end
elsif x <= number
puts x.to_s + " is too end!"
count = count + 1
if count == 6
puts "You have 1 chance left."
else puts "You have " + count.to_s + " chances left."
end
elsif x == number
puts "Correct! You have the right number!"
break
end
x = gets.chomp
end
if count == 7
puts "You've lost."
x = 0
count = 0
number = rand(101)
end