Guest User

Untitled

a guest
Jul 20th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * животное
  5. */
  6. class Animal
  7. {
  8.  
  9. private $name;
  10.  
  11. /**
  12. * создать животное
  13. * @param string $name имя
  14. */
  15. public function __construct($name)
  16. {
  17. $this->name = $name;
  18. }
  19.  
  20. /**
  21. * узнать имя
  22. * @return string $name
  23. */
  24. public function getName()
  25. {
  26. return $this->name;
  27. }
  28.  
  29. }
  30.  
  31. /**
  32. * кот
  33. */
  34. class Cat extends Animal
  35. {
  36.  
  37. /**
  38. * @return string «Cat {name} is saying meow»
  39. */
  40. public function meow()
  41. {
  42. return 'Cat ' . $this->getName() . ' is saying meow';
  43. }
  44.  
  45. }
  46.  
  47. $cat = new Cat ('garfield');
  48.  
  49. echo $cat->getName() . '<br>';
  50.  
  51. echo $cat->meow();
Add Comment
Please, Sign In to add comment