Skip to content

Instantly share code, notes, and snippets.

@ruxandrafed
Forked from davidvandusen/shakil_the_dog.rb
Last active September 1, 2015 21:27
Show Gist options
  • Save ruxandrafed/70508c6bdc97f325aee7 to your computer and use it in GitHub Desktop.
Save ruxandrafed/70508c6bdc97f325aee7 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 get_user_input
puts "What do you want to say to the dog?"
user_input = gets.chomp
end
def check_user_input(string)
case string
when "woof"
puts "WOOF WOOF WOOF"
when "meow"
puts "woof woof woof woof woof"
else
if string.downcase.include?("shakil stop") || string.downcase.include?("treat")
puts "Nothing happens"
end
end
end
def shakil_the_dog
begin
user_input = get_user_input
check_user_input(user_input)
end until user_input == "go away"
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