Skip to content

Instantly share code, notes, and snippets.

@tarynsauer
Last active December 19, 2015 01:29
Show Gist options
  • Save tarynsauer/5875974 to your computer and use it in GitHub Desktop.
Save tarynsauer/5875974 to your computer and use it in GitHub Desktop.
Guessing Game
class GuessingGame
attr_reader :answer
def initialize(answer)
@answer = answer
end
def guess(guess)
last_guess = guess.to_i
if last_guess > @answer
last_result = :high
elsif last_guess < @answer
last_result = :low
else
last_result = :correct
end
last_result
end
def solved?
self.guess == :correct
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment