Created
August 10, 2016 19:57
-
-
Save dylanerichards/0d0828991c5e07d9ac1a407e88ff35d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class NumberGuessingGame | |
def initialize | |
p @number = rand(0..9).to_s | |
end | |
def guess | |
puts "I'm thinking of a random number from 0 to 9" | |
puts "Can you guess it?" | |
input = gets.chomp | |
if input == @number | |
puts 'You got. It took it' | |
elsif input > @number | |
puts 'Too high' | |
guess | |
elsif input < @number | |
puts 'Too Low' | |
guess | |
end | |
end | |
end | |
# Tests | |
game = NumberGuessingGame.new | |
game.guess |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment