Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exercise Shakil The Dog
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