Created
October 29, 2010 03:03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try to figure out if there is a way to chomp & convert to an integer on | |
# same line (lines 7 and 8) | |
# Try to figure out how to print failure message (lines 14-16 & 20-22) for | |
# both cases in which the user is incorrect without having it in the program | |
# twice. | |
randNumber = rand(10) | |
randNumber = randNumber + 1 | |
print( 'Guess my number! Enter a number (1-10): ') | |
userNumber = gets.chomp.to_i() | |
if userNumber == randNumber | |
puts( 'You guessed correctly! You are SOOO smart!') | |
elsif userNumber > randNumber | |
puts( "Your number (#{userNumber}) is higher than my number (#{randNumber}.") | |
print( "You are unable to guess again because you are such a failure. It | |
has nothing to do with my inability to program this such that you could | |
guess again.") | |
else | |
puts( "Your number (#{userNumber}) is lower than my number (#{randNumber}.)") | |
print( "You are unable to guess again because you are such a failure. It | |
has nothing to do with my inability to program this such that you could | |
guess again.") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment