Created
November 5, 2011 19:50
-
-
Save inertialbit/1341931 to your computer and use it in GitHub Desktop.
quick and dirty arithmetic cli
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
def ask question | |
print question | |
STDIN.gets.chomp | |
end | |
new_problem = true | |
10.times do | |
if new_problem | |
one = rand(10) | |
two = rand(10) | |
end | |
answer = ask "#{one} + #{two} = " | |
if answer == (one + two).to_s | |
print "Great Job!! `-_-`\n\n" | |
new_problem = true | |
else | |
print "Nope! Try again!!\n\n" | |
new_problem = false | |
redo | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment