Correction status:qualified
Teacher's comments:
<?php class Vehicle { protected $country; protected $brand; protected $displacement; protected $price; public function __contruct($brand, $model, $displacement, $price) { $this->country = $country; $this->brand = $brand; $this->displacement = $displacement; $this->price = $price; } public function engineStart() { return '发动机启动'; } }
点击 "运行实例" 按钮查看在线实例
<?php require './Vehicle.php'; class Roderster extends Vechile { private $door = 2; private $seat = 2; // 必须使用构造方法对使用当前新增属性生效 public function __construct($country, $brand, $model, $displacement, $price, $door, $seat) { // 调用父类构造器初始化类属性 parent::__construct($country, $brand, $model, $displacement, $price); $this->door = $door; $this->seat = $seat; } public function catchGirl() { return '带上小姐姐'; } public function engineStart() { return parent::engineStart(). '声音悦耳;'; } }
点击 "运行实例" 按钮查看在线实例