Ответов: 7 Просмотров: 1748
|
есть абстрактный класс
PHP:
скопировать код в буфер обмена
<?PHP /** * Created by PhpStorm. * User: ivan * Date: 22.10.14 * Time: 11:55 */ /*Абстрактный класс Abstractbicycle в котором есть переменные: фирма, вес, количество скоростей. Велосипед может катиться и остановиться */ /* В абстрактном классе Abstractbicycle есть абстрактный метод show()*/ abstract class AbstractBicycle { public $brand; public $weight; public $speedNumber; abstract public function show(); /*================Set Values==================*/ public function setBrand($brand) { $this->brand = $brand; } public function setWeight($weight) { $this->weight = $weight; } public function setSpeedNumber($speedNumber) { $this->$speedNumber = $speedNumber; } /*================Get Values===================*/ public function getBrand() { return $this->brand; } public function getWeight() { return $this->weight; } public function getSpeedNumber() { return $this->speedNumber; } public function roll() { return 'rolling'; } public function brake() { return 'brake'; } }
есть наследник
PHP:
скопировать код в буфер обмена
class LeaderFox extends AbstractBicycle { public function __constructor($brand, $weight, $speedNumber) { $this->getBrand($brand); $this->getWeight($weight); $this->getSpeedNumber($speedNumber); } public function show() { return sprintf('This %s is %.3f %d',"{$this->getBrand()}", "{$this->getWeight()}", "{$this->getSpeedNumber()}"); } }
и есть исполняемый файл
PHP:
скопировать код в буфер обмена
<?PHP require_once 'AbstractBicycle.php'; require_once 'LeaderFox.php'; $LeaderFox = new LeaderFox('LeaderFox','9.5','14'); echo $LeaderFox->show().'<br>';
но почему то при создание объекта класса и последующему вызову функции show() выводит такой результат:
This is 0.000 0<br>
а должен
This LeaderFox is 9.5000 14
Почему не передаються параметры? |