<?php
class Car {
??? public $speed = 0; //汽車的起始速度是0
?? ?
??? public function speedUp() {
??????? $this->speed += 10;
??????? return $this->speed;
??? }
}
//定義繼承于Car的Truck類
class Truck extends Car {
??? public $speed = 50; //卡車的速度是50
}
$car = new Truck();
// $car->speedUp();
echo $car->speed;
要將 $car->speedUp();注釋掉,就行啦
2014-11-21
class Car {
? ? public $speed = 0; //汽車的起始速度是0
? ??
? ? public function speedUp() {
? ? ? ? $this->speed += 10;
? ? ? ? return $this->speed;
? ? }
}
//定義繼承于Car的Truck類
class Truck extends Car{
? ? public function speedUp(){
? ? ? ? $this->speed += 60;
? ? }
}
$car = new Truck();
$car->speedUp();
echo $car->speed;
這么寫才符合任務需求
2014-12-16
你那么寫,還不如直接echo 出50得了,糊弄自己沒有用啊
2014-11-08
什么呀,明顯不符合要求;