Created
June 24, 2013 23:00
-
-
Save mjseaman/5854509 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
| # 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