1. class Animal
  2. def initialize name
  3. @name = name
  4. end
  5. def run
  6. print "#{name} running\n"
  7. eat
  8. end
  9. private
  10. def eat
  11. print "eating\n"
  12. end
  13. end
  14. class Cat < Animal.new
  15. def initialize
  16. super "cat"
  17. end
  18. def jump
  19. print "#{name} jumping"
  20. end
  21. end
  22. cat = Cat.new
  23. cat.run
  24. cat.jump
Comments powered by Disqus