Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class Bird
  4. {
  5. abstract public function getName();
  6. }
  7.  
  8. interface IFlayer
  9. {
  10. public function fly(): int;
  11. }
  12.  
  13. interface ISwimmer
  14. {
  15. public function swim(): int;
  16. }
  17.  
  18. class Duck extends Bird implements IFlayer, ISwimmer {
  19. public function getName(): string
  20. {
  21. return 'Donald Duck';
  22. }
  23.  
  24. public function fly(): int
  25. {
  26. return 10;
  27. }
  28.  
  29. public function swim() : int
  30. {
  31. return 3;
  32. }
  33. }
  34.  
  35. $duck = new Duck();
  36. echo $duck->getName() . PHP_EOL;
  37. echo $duck->swim() . PHP_EOL;
  38. echo $duck->fly() . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement