Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "Aplication.php";
- include "Video.php";
- class VideoStore
- {
- private array $videos = [];
- public function addVideo(string $name):void
- {
- $this->videos[] = new Video($name);
- }
- public function getVideoList()
- {
- /** @var Video $video */
- foreach ($this->videos as $video) {
- echo $video->showVideo() . PHP_EOL;
- }
- }
- public function rentVideo()
- {
- /** @var Video $video */
- $selected = readline("Enter Video Title to rent Video : ");
- foreach ($this->videos as $video) {
- if ($video->getName() === $selected && $video->getAvailability() === true) {
- $video->rentVideo();
- }else{
- echo "Video already rented or Title not Correct!";
- }
- }
- }
- public function returnVideo()
- {
- $videoToReturn = readline("Enter Video Title to return Video : ");
- /** @var Video $video */
- foreach ($this->videos as $video) {
- if ($video->getName() === $videoToReturn && $video->getAvailability() === false)
- {
- $userRating = readline("Please leave your rating for this Video (1-10) : ");
- $video->setRating($userRating);
- $video->returnVideo();
- }else {
- echo "Video already available or Title not Correct!";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement