I have the following classes:
<?php class Person extends Academy { public $name; public function __construct($name) { $this->name = $name; } public function ShowData() { return ['name' => $this->name]; } } class Student extends Person { public $education; public function __construct($name, $education) { parent::__construct($name); $this->education = $education; } public function showData() { return array_merge(parent::showData(), [ 'education' => $this->education ]); } } class Worker extends Person{ public $workPlace; public function __construct($name, $workPlace) { parent::__construct($name); $this->workPlace = $workPlace; } public function showData() { return array_merge(parent::showData(), [ 'workPlace' => $this->workPlace ]); } } ?> And their parent class:
<?php class Academy { private $items = array(); public function showAll($key) { … } public function addPerson($obj, $key = null) { … } } ?> I need to implement the showAll (shows Name, Education, and WorkPlace for all people) and addPerson (adds a new person to the Academy). I understand that derived classes have a showDate method and the showAll method can get data with it, but I do not know how to implement it.
$key? - vp_arth