dimanche 1 mars 2015

Guessing game for ruby

I'm currently trying to create a simply made guessing game, In the code there will be three set number (for now) that a person has to guess. If he/she guesses all the numbers correctly it puts, "Congrats, you win!"


Now as a beginning test i just wanted the user to guess one number correctly and the code gives back correct or incorrect.



random_guess = [1, 3, 5]

puts "Please Pick a number, 1-5"
pick_num = gets.chomp

if pick_num == random_guess = true
puts "Correct!"
else
puts "Incorrect!"
end


(I know this code is very beginner, i'm very new to ruby.) for some reason every time i run this program it puts incorrect.


Aucun commentaire:

Enregistrer un commentaire