Skip to content

Instantly share code, notes, and snippets.

@Andsbf
Created March 4, 2015 01:43
Show Gist options
  • Save Andsbf/ece158ea552bb5b62341 to your computer and use it in GitHub Desktop.
Save Andsbf/ece158ea552bb5b62341 to your computer and use it in GitHub Desktop.
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