fork download
  1. <?php
  2.  
  3. abstract class AbstractShit
  4. {
  5. private $color;
  6. private $weight; // В килограммах
  7. private $smell;
  8.  
  9. abstract function eat();
  10. public function smearYourself() { /* Можно ли задать тут реализацию по умолчанию? */ }
  11. }
  12.  
  13. class Shit extends AbstractShit
  14. {
  15. public function eat()
  16. {
  17. echo 'Ням, ням, ням!';
  18. }
  19. public function smearYouself()
  20. {
  21. echo 'Уфф, уфф!';
  22. }
  23. }
  24.  
  25. $shit = new Shit;
  26. $shit->color = 'Темно-зеленый';
  27. $shit->weight = 0.5;
  28. $shit->smell = 'Как земля';
  29. $shit->eat();
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Ням, ням, ням!