Skip to content

Instantly share code, notes, and snippets.

@shinobcrc
Forked from davidvandusen/shakil_the_dog.rb
Last active June 22, 2016 03:01
Show Gist options
  • Save shinobcrc/baffe99ac99a12a6db2bb4422abc8b0e to your computer and use it in GitHub Desktop.
Save shinobcrc/baffe99ac99a12a6db2bb4422abc8b0e to your computer and use it in GitHub Desktop.
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def shakil_the_dog
puts "Shakil is waiting for your response"
while true
your_response = gets.strip
case your_response
when "woof"
puts "WOOF WOOF WOOF"
when "shakil stop" || "Shakil STOP!"
puts "Shakil is quiet"
when "meow"
puts "woof woof woof woof woof"
when /(treat)/
puts "Shakil is quiet waiting for his treat"
when "go away"
puts "Shakil left you alone"
break
else
puts "Shakil doesn't understand you!"
end
end
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