/deaf_aunty.rb Secret
Last active
August 29, 2015 14:26
-
-
Save wen-yuxiang/25587614d979742e8382 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_aunty.rb | |
| # | |
| # Your method should wait for user input, which corresponds | |
| # to you saying something to your Aunty. | |
| # You'll probably want to write other methods, but this | |
| # encapsulates the core Aunty logic | |
| def deaf_aunty | |
| sentinel = 0 | |
| puts "Do you want to talk to your aunt? If yes please say something" | |
| while (sentinel<2) | |
| input = gets.chomp | |
| if (input.downcase == "i love ya, aunty, but i've got to go.") | |
| puts "Goodbye dear" | |
| break | |
| elsif input == "" | |
| sentinel += 1 | |
| elsif (input == input.upcase) | |
| puts "NO, WE CAN'T DO THAT!" | |
| sentinel = 0 | |
| else | |
| puts "HUH?! SPEAK UP, SANDRA!" | |
| sentinel = 0 | |
| end | |
| end | |
| end | |
| # Run our method | |
| deaf_aunty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment