Skip to content

Instantly share code, notes, and snippets.

@jkarnowski
Created March 22, 2016 06:19
Show Gist options
  • Select an option

  • Save jkarnowski/b8cc90ad32a5e0f9a210 to your computer and use it in GitHub Desktop.

Select an option

Save jkarnowski/b8cc90ad32a5e0f9a210 to your computer and use it in GitHub Desktop.
# 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