Last active
August 29, 2015 14:10
-
-
Save hpjaj/f312ee899dc4d98213db to your computer and use it in GitHub Desktop.
Week 3 - 6e - Deaf Granny Part 1
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
| def sonny_says | |
| puts "Sonny says:" | |
| print "> " | |
| @what_sonny_says = gets.chomp | |
| end | |
| def random_year_generator(starting_year, ending_year) | |
| @random_year = rand(starting_year..ending_year) | |
| end | |
| def grandas_response(sonny_said) | |
| print "Grandma responds: " | |
| if sonny_said == sonny_said.upcase | |
| puts "NO, NOT SINCE #{@random_year}!" | |
| else | |
| puts "HUH?! SPEAK UP, SONNY!" | |
| end | |
| end | |
| def sonnys_conversation_with_grandma | |
| loop do | |
| random_year_generator(1930, 1950) | |
| grandas_response(sonny_says) | |
| if @what_sonny_says == 'BYE' | |
| puts "OH, NEVERMIND. GOODBYE SONNY." | |
| break | |
| end | |
| end | |
| end | |
| sonnys_conversation_with_grandma |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment