Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Fish
- {
- public $common_name;
- public $flavor;
- public $record_weight;
- public $output;
- function __construct($name, $flavor, $record){
- $this->common_name = $name;
- $this->flavor = $flavor;
- $this->record_weight = $record;
- }
- public function getInfo() {
- $output = "The {$this->common_name} is an awesome fish. ";
- $output .= "It is very {$this->flavor} when eaten. ";
- $output .= "Currently the world record {$this->common_name} weighed {$this->record_weight}.";
- return $output;
- }
- }
- class Trout extends Fish {
- public $species;
- public function __construct($name, $flavor, $record, $species) {
- parent::__construct($name, $flavor, $record);
- $this->species = $species;
- }
- public function getInfo() {
- $output = "{$this->species} {$this->common_name} taste {$this->flavor}. The record {$this->species} {$this->common_name} weighed {$this->record_weight}";
- echo $output;
- }
- }
- $brook_trout = new Trout("Trout", "Delicious", "14 pounds 8 ounces", "Brook");
- $brook_trout->getInfo();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement