daily pastebin goal
58%
SHARE
TWEET

ThemePark.php

a guest Feb 14th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: crhar
  5.  * Date: 2/14/2018
  6.  * Time: 2:52 PM
  7.  */
  8.  
  9. require_once $_SERVER['DOCUMENT_ROOT'] . '/Classes/Ride.php';
  10. require_once $_SERVER['DOCUMENT_ROOT'] . '/Classes/Patron.php';
  11.  
  12. class ThemePark
  13. {
  14.     private $parkName;
  15.     private $location;
  16.     private $rides = array();
  17.  
  18.     public function __construct($parkName, $location)
  19.     {
  20.         $this->parkName = $parkName;
  21.         $this->location = $location;
  22.     }
  23.  
  24.     /**
  25.      * @return mixed
  26.      */
  27.     public function getParkName()
  28.     {
  29.         return $this->parkName;
  30.     }
  31.  
  32.     /**
  33.      * @param mixed $parkName
  34.      */
  35.     public function setParkName($parkName)
  36.     {
  37.         $this->parkName = $parkName;
  38.     }
  39.  
  40.     /**
  41.      * @return mixed
  42.      */
  43.     public function getLocation()
  44.     {
  45.         return $this->location;
  46.     }
  47.  
  48.     /**
  49.      * @param mixed $location
  50.      */
  51.     public function setLocation($location)
  52.     {
  53.         $this->location = $location;
  54.     }
  55.  
  56.     public function addARide($minHeightInches, $name, $type)
  57.     {
  58.         $ride = new Ride($minHeightInches, $name, $type);
  59.         $this->rides[$name] = $ride;
  60.     }
  61.  
  62.     public function removeARide($name)
  63.     {
  64.         try
  65.         {
  66.             unset($this->rides[$name]);
  67.         }
  68.         catch (Exception $e)
  69.         {
  70.             die($e->getMessage());
  71.         }
  72.     }
  73.  
  74.     public function numberOfRidesThatAreThrillers()
  75.     {
  76.         $number = 0;
  77.  
  78.         foreach ($this->rides as $ride)
  79.         {
  80.             if($ride->getType() == 'Thriller')
  81.             {
  82.                 $number++;
  83.             }
  84.         }
  85.         return $number;
  86.     }
  87.  
  88.     public function addAPatronToARide($name, $rideName, $heightFT, $heightInches, $likeThrill)
  89.     {
  90.         if ($this->rides[$rideName] == true)
  91.         {
  92.             $ride = $this->rides[$rideName];
  93.             $ride->addPatron($name, $heightFT, $heightInches, $likeThrill);
  94.         }
  95.         else
  96.         {
  97.             echo "The ride does not exist!";
  98.         }
  99.     }
  100.  
  101.     public function removeAPatronFromARide($rideName, $patronName)
  102.     {
  103.         $this->rides[$rideName]->removePatron($patronName);
  104.     }
  105.  
  106.     public function displayPeopleOnARide($rideName)
  107.     {
  108.         //This isn't working properly
  109.         foreach ($this->rides[$rideName] as $ride)
  110.         {
  111.             return $ride->getPatrons();
  112.         }
  113.     }
  114. }
  115.  
  116. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top