Advertisement
Guest User

Store

a guest
Apr 2nd, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. include "Aplication.php";
  3. include "Video.php";
  4.  
  5.  
  6.  
  7. class VideoStore
  8. {
  9. private array $videos = [];
  10.  
  11.  
  12. public function addVideo(string $name):void
  13. {
  14. $this->videos[] = new Video($name);
  15. }
  16.  
  17. public function getVideoList()
  18. {
  19. /** @var Video $video */
  20. foreach ($this->videos as $video) {
  21. echo $video->showVideo() . PHP_EOL;
  22. }
  23. }
  24.  
  25. public function rentVideo()
  26. {
  27. /** @var Video $video */
  28. $selected = readline("Enter Video Title to rent Video : ");
  29. foreach ($this->videos as $video) {
  30. if ($video->getName() === $selected && $video->getAvailability() === true) {
  31. $video->rentVideo();
  32. }else{
  33. echo "Video already rented or Title not Correct!";
  34. }
  35.  
  36. }
  37. }
  38.  
  39. public function returnVideo()
  40. {
  41.  
  42. $videoToReturn = readline("Enter Video Title to return Video : ");
  43.  
  44. /** @var Video $video */
  45. foreach ($this->videos as $video) {
  46. if ($video->getName() === $videoToReturn && $video->getAvailability() === false)
  47. {
  48. $userRating = readline("Please leave your rating for this Video (1-10) : ");
  49. $video->setRating($userRating);
  50. $video->returnVideo();
  51.  
  52. }else {
  53. echo "Video already available or Title not Correct!";
  54. }
  55.  
  56. }
  57. }
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement