Advertisement
jargot

Untitled

Mar 13th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 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.     public function getInfo() {
  35.       $output =  "{$this->species} {$this->common_name} taste {$this->flavor}. The record {$this->species} {$this->common_name} weighed {$this->record_weight}";
  36.       echo $output;
  37.       }
  38.  
  39.  
  40. }
  41.  
  42. $brook_trout = new Trout("Trout", "Delicious", "14 pounds 8 ounces", "Brook");
  43. $brook_trout->getInfo();
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement