$this->health = 150; } public function pet() { $this->health += 5; } } $dog = new dog("dog"); $dog->walk()->walk()->walk()->run()->run()->pet(); echo $dog->displayHealth(); echo "<br>"; class dragon extends animal { public function __construct($name) { $this->health = 170; $this->name = $name; echo "<br>this is a dragon!"; } public function fly() { $this->health -= 10; return $this; } } $dragon = new dragon("dragon"); $dragon->walk()->walk()->walk()->run()->run()->fly()->fly(); echo $dragon->displayHealth(); echo "<br>"; $animal->pet(); $animal->fly();
echo "<br>"; return $this; } } class dragon extends animal { public function __construct($name) { parent::__construct($name); $this->health = 170; } public function fly() { echo "Flying..... "; echo "<br>"; $this->health -= 10; return $this; } public function display_health() { echo "This is a dragon"; echo "<br>"; parent::display_health(); } } $animal1 = new animal("Rhino"); $animal1->walk()->walk()->walk()->run()->run()->display_health(); $animal2 = new dog("Lance the dog walker"); $animal2->walk()->walk()->walk()->run()->run()->pet()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->run()->walk()->walk()->walk()->display_health(); $animal3 = new dragon("Elysian"); $animal3->walk()->walk()->walk()->run()->run()->fly()->fly()->display_health();