Last active
August 29, 2015 14:10
-
-
Save jacksy40/1a2e858801c3949b4c95 to your computer and use it in GitHub Desktop.
Deaf Grandma
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
| #grandma excercise | |
| puts ' Hi grandchild how are you? ' | |
| while true | |
| response = gets.chomp | |
| if response == 'BYE' | |
| break | |
| end | |
| if response == response.upcase | |
| puts 'NO, NOT SINCE..' + (rand(1950-1930)+1930).to_s | |
| puts | |
| else | |
| puts 'HUH? SPEAK UP, SONNY!' | |
| end | |
| end | |
| puts ' I\'LL TALK TO YOU LATER SONNY!' | |
| # extended grandma | |
| bye = 0 | |
| puts ' Hi grandchild how are you? ' | |
| while bye < 3 | |
| response = gets.chomp | |
| if response == 'BYE' | |
| bye = bye + 1 | |
| else | |
| bye = 0 | |
| end | |
| if response == response.upcase | |
| puts 'NO, NOT SINCE..' + (rand(1950-1930)+1930).to_s | |
| puts | |
| else | |
| puts 'HUH? SPEAK UP, SONNY!' | |
| end | |
| end | |
| puts ' I\'LL TALK TO YOU LATER SONNY!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment