Skip to content

Instantly share code, notes, and snippets.

@mjseaman
Created June 24, 2013 23:00
Show Gist options
  • Select an option

  • Save mjseaman/5854509 to your computer and use it in GitHub Desktop.

Select an option

Save mjseaman/5854509 to your computer and use it in GitHub Desktop.
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby deaf_grandma.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your Grandma.
# You'll probably want to write other methods, but this
# encapsulates the core Grandma logic
def deaf_grandma
puts "Hello Deary, How are you?\n"
input = ""
counter = 0
while counter < 2
input = gets.chomp
if input == "I love ya, Grandma, but I've got to go."
puts "Dont Leave yet"
counter = 0
break
elsif input == ""
counter += 1
puts "Please don't go. I'm old and lonely."
elsif input == input.upcase
puts "NO, NOT SINCE 1983!"
counter = 0
else
puts "HUH?! SPEAK UP, SONNY!"
counter = 0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment