Created
March 22, 2016 06:19
-
-
Save jkarnowski/b8cc90ad32a5e0f9a210 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
| # Get input from the user: the cheer | |
| def call_out_cheer | |
| puts "Give me a shout!" | |
| cheer = gets.chomp | |
| end | |
| # Determine the mascot's response based on the argument | |
| # passed to the method | |
| def mascot_sign_for(input) | |
| # store the cheers in a hash because they seem like key-value pairs | |
| known_cheer = { | |
| "RED HOT" => "H-O-T!", | |
| "DO IT AGAIN" => "Go, Fight, Win", | |
| "2 BITS" => "Holler!", | |
| "STOMP YOUR FEET" => "STOMP!" | |
| } | |
| # 3 types of input: | |
| if input == "GAME OVER" | |
| exit | |
| elsif known_cheer[input] != nil | |
| p known_cheer[input] | |
| else | |
| return "Go Team!" | |
| end | |
| end | |
| # Print the argument passed to the method | |
| def display(response) | |
| p response | |
| end | |
| # This method will control the flow of the application, | |
| # making use of the other three methods. | |
| def coordinate_cheers | |
| display(mascot_sign_for(call_out_cheer)) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment