Created
July 19, 2016 23:43
-
-
Save jkirkpatrick24/0be5988041be968a4e82528bf3c8f54e to your computer and use it in GitHub Desktop.
Chat with Shakil!
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 talk | |
| while true | |
| print "Talk to shakil " | |
| input = gets.strip | |
| return input if input.length > 0 | |
| puts "Invalid input" | |
| end | |
| end | |
| def conversation(talk) | |
| case talk | |
| when 'woof' | |
| output = 'WOOF WOOF WOOF' | |
| when 'meow' | |
| output = 'woof woof woof woof woof' | |
| when /shakil down/i | |
| output = "shakil goes quiet for a few precious seconds" | |
| when /treat/ | |
| output = 'shakil stares at you just wanting a treat' | |
| when 'go away' | |
| return false | |
| else | |
| output = 'shak doesnt understand' | |
| end | |
| end | |
| def shakil_the_dog | |
| while true | |
| input = talk | |
| output = conversation(input) | |
| break unless output | |
| puts output | |
| end | |
| puts 'shakil left' | |
| end | |
| # Run our method | |
| shakil_the_dog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment