Created
March 4, 2015 01:43
-
-
Save Andsbf/ece158ea552bb5b62341 to your computer and use it in GitHub Desktop.
Exercise Shakil The Dog
This file contains 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 user_input | |
puts "what do you have to say to Shakil(dog):" | |
gets.chomp | |
end | |
def shakil_behavior(user_input) | |
user_input = "treat" if user_input.include? "treat" | |
case user_input | |
when "woof" | |
return "WOOF WOOF WOOF" | |
when "shakil stop" , "Shakil STOP!" | |
return "" | |
when "meow" | |
return "woof woof woof woof woof" | |
when "treat" | |
return "" | |
when "go away" | |
return "*dog leaves*" | |
else | |
return "Woof" | |
end | |
end | |
def situation | |
while true | |
result = shakil_behavior(user_input) | |
return if result == "*dog leaves*" | |
puts "Shakil says: " + result | |
end | |
end | |
situation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment