Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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
- run_program = true
- while run_program
- puts "Shakil looks at you, what do you say?"
- you_say = gets.chomp
- you_say.downcase!
- if you_say.include? "treat"
- puts "wags tail expectantly"
- else
- case you_say
- when "shakil stop"
- puts "..."
- when "meow"
- puts "woof woof woof woof woof"
- when "woof"
- puts "WOOF WOOF WOOF"
- when "go away"
- run_program = false
- else
- puts "woof"
- end
- end
- end
- end
- # Run our method
- shakil_the_dog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement