Example #1
0
    {
        echo 'It is an elephant<br>Name: ' . $this->name . '<br>Age: ' . $this->age . '<br>Sex: ' . $this->sex . '<br>Destination: ' . $this->destination . '<br><br>';
    }
}
class Giraffe extends Mamal
{
    public $necklength;
    public function __construct($name, $age, $sex, $necklength)
    {
        parent::__construct($name, $age, $sex);
        $this->necklength = $necklength;
    }
    public function info()
    {
        echo 'It is an giraffe<br>Name: ' . $this->name . '<br>Age: ' . $this->age . '<br>Sex: ' . $this->sex . '<br>Necklength: ' . $this->necklength . '<br><br>';
    }
}
$mike = new Animal('Mike', 29);
$mike->info();
$amphimike = new Amphibian('Amphimike', 29, 'true');
$amphimike->info();
$frogmike = new Frog('Frogmike', 29, 'false', 'green');
$frogmike->info();
$tritonmike = new Triton('Mike', 31, 'true', '20 mm');
$tritonmike->info();
$mamalmike = new Mamal('Mamalmike', '18', 'male');
$mamalmike->info();
$elephantmike = new Elephant('Mike', 12, 'female', 'India');
$elephantmike->info();
$giraffemike = new Giraffe('Nina', 4, 'female', '2m');
$giraffemike->info();
Example #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Frog::model()->findByPk($id);
     if ($model === null) {
         $this->sendAjaxResponse(new NotFoundException());
     }
     return $model;
 }
Example #3
0
 protected function addFrog($frog)
 {
     $f = new Frog($frog);
     $f->setId(count($this->frogs) ? $this->frogs[count($this->frogs) - 1]->getId() + 1 : 1);
     $this->frogs[] = $f;
 }