Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class Movie
  4. {
  5.  
  6. }
  7.  
  8. class CoolMovie extends Movie implements MovieInterface
  9. {
  10. public function getTitle(): string
  11. {
  12. return 'Spider man';
  13. }
  14.  
  15. public function getRating(): int
  16. {
  17. return 10;
  18. }
  19. }
  20.  
  21. class MiniMovie extends Movie implements MovieInterface
  22. {
  23. public function getTitle(): string
  24. {
  25. return 'Super mini movie';
  26. }
  27.  
  28. public function getRating(): int
  29. {
  30. return 7;
  31. }
  32. }
  33.  
  34. class SuperMovie extends Movie implements MovieInterface
  35. {
  36. public function getTitle(): string
  37. {
  38. return 'Super movie';
  39. }
  40.  
  41. public function getRating(): int
  42. {
  43. return 11;
  44. }
  45. }
  46.  
  47. interface MovieInterface
  48. {
  49. public function getTitle(): string;
  50. public function getRating(): int;
  51. }
  52.  
  53. $coolMovie = new CoolMovie();
  54. $miniMovie = new MiniMovie();
  55. $superMovie = new SuperMovie();
  56.  
  57. function getMovie(MovieInterface $movie)
  58. {
  59. return $movie->getRating();
  60. }
  61.  
  62. echo getMovie($coolMovie) . PHP_EOL;
  63. echo getMovie($miniMovie) . PHP_EOL;
  64. echo getMovie($superMovie) . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement