Skip to content

Instantly share code, notes, and snippets.

@dylanerichards
Created August 10, 2016 19:57
Show Gist options
  • Save dylanerichards/0d0828991c5e07d9ac1a407e88ff35d6 to your computer and use it in GitHub Desktop.
Save dylanerichards/0d0828991c5e07d9ac1a407e88ff35d6 to your computer and use it in GitHub Desktop.
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