Last active
December 20, 2015 15:49
-
-
Save MrBean83/6157398 to your computer and use it in GitHub Desktop.
"Build a simple guessing game"
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 GuessingGame | |
| def initialize(answer) | |
| @answer = answer | |
| end | |
| def guess(guess) | |
| @guess = guess | |
| result = nil | |
| case guess | |
| when guess == @answer | |
| result = :correct | |
| when guess > @answer | |
| result = :high | |
| when guess < @answer | |
| result = :low | |
| end | |
| result | |
| end | |
| def solved? | |
| if @guess == @answer | |
| true | |
| else | |
| false | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My guess is a syntax error. Look through this