Skip to content

Instantly share code, notes, and snippets.

@stupeters187
Created March 29, 2016 20:27
Show Gist options
  • Save stupeters187/03a5948f293c2236d1291af1ccccb6ea to your computer and use it in GitHub Desktop.
Save stupeters187/03a5948f293c2236d1291af1ccccb6ea 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
# loop do
# puts "What do you do(bark, scold, meow, say go away, say treat)?"
# answer = gets.chomp
# answer.downcase!
# if answer == 'bark'
# puts "Shakil: WOOF WOOF WOOF"
# elsif answer == 'scold'
# puts "Shakil: ......"
# elsif answer == 'meow'
# puts "Shakil: woof woof woof woof woof"
# elsif answer == 'say treat'
# puts "*Shakil sits*"
# elsif answer == 'say go away'
# puts "*Shakil leaves*"
# break
# else
# puts "woof"
# end
# end
# end
def shakil_the_dog
loop do
puts "What do you do(bark, scold, meow, say treat, say go away)?"
answer = gets.chomp
answer.downcase!
case answer
when 'bark'
puts "Shakil: WOOF WOOF WOOF"
when 'scold'
puts "Shakil: ......"
when 'meow'
puts "Shakil: woof woof woof woof woof"
when 'say treat'
puts "*Shakil sits*"
when 'say go away'
puts "*Shakil leaves*"
break
else
puts 'woof'
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