Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # Save this file to your computer so you can run it
  2. # via the command line (Terminal) like so:
  3. # $ ruby shakil_the_dog.rb
  4. #
  5. # Your method should wait for user input, which corresponds
  6. # to you saying something to your dog (named Shakil).
  7.  
  8. # You'll probably want to write other methods, but this
  9. # encapsulates the core dog logic
  10. def shakil_the_dog
  11.  
  12. run_program = true
  13.  
  14. while run_program
  15.  
  16. puts "Shakil looks at you, what do you say?"
  17. you_say = gets.chomp
  18. you_say.downcase!
  19.  
  20. if you_say.include? "treat"
  21. puts "wags tail expectantly"
  22. else
  23. case you_say
  24. when "shakil stop"
  25. puts "..."
  26. when "meow"
  27. puts "woof woof woof woof woof"
  28. when "woof"
  29. puts "WOOF WOOF WOOF"
  30. when "go away"
  31. run_program = false
  32.  
  33. else
  34. puts "woof"
  35. end
  36. end
  37. end
  38. end
  39.  
  40. # Run our method
  41. shakil_the_dog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement