Stratician

PHP Classes

Jan 27th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. <?php
  2.  
  3.         class Hotel
  4.         {
  5.             public $name;
  6.             public $rooms = 200;
  7.             public $booked = 80;
  8.             public $hasPool; // Boolean Value
  9.  
  10.             public function roomsAvailable()
  11.             {
  12.                 return $this->rooms - $this->booked;
  13.             }
  14.  
  15.         }
  16.  
  17.         $ReubenInn = new Hotel;
  18.  
  19.         $ReubenInn->name = "ReubenInn";
  20.         $ReubenInn->hasPool = true;
  21.  
  22.         echo "There are " . $ReubenInn->roomsAvailable() . " rooms available";
  23.  
  24.     ?>
Advertisement
Add Comment
Please, Sign In to add comment