Advertisement
jargot

Untitled

Mar 13th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2.  
  3. class Fish
  4. {
  5.     public $common_name;
  6.     public $flavor;
  7.     public $record_weight;
  8.     public $output;
  9.  
  10.     function __construct($name, $flavor, $record){
  11.         $this->common_name = $name;
  12.         $this->flavor = $flavor;
  13.         $this->record_weight = $record;
  14.     }
  15.  
  16.     public function getInfo() {
  17.  
  18.         $output  = "The {$this->common_name} is an awesome fish. ";
  19.         $output .= "It is very {$this->flavor} when eaten. ";
  20.         $output .= "Currently the world record {$this->common_name} weighed {$this->record_weight}.";
  21.         return $output;
  22.     }
  23. }
  24.  
  25. class Trout extends Fish {
  26.   public $species;
  27.   public function __construct($name, $flavor, $record, $species) {
  28.     parent::__construct($name, $flavor, $record);
  29.     $this->species = $species;
  30.   }
  31.    
  32.    
  33.   /*
  34.  
  35.     public function getInfo() {
  36.       $output =  "{$this->common_name} {$this->species} taste {$this->flavor}. The record {$this->common_name} {$this->species} weighed {$this->record_weight}";
  37.       echo $output;
  38.       }
  39.  
  40.     */
  41.  
  42.       public function getInfo() {
  43.         parent::getInfo();
  44.         $output = $output . " And this is true too!";
  45.         echo $output;
  46.       }
  47. }
  48.  
  49. $brook_trout = new Trout("Trout", "Delicious", "14 pounds 8 ounces", "Brook");
  50. $brook_trout->getInfo();
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement