小明的方法為什么不能覆蓋父類?
<?php
header("Content-type: text/html; charset=utf-8");
class SportObject
{
public $name;
public $age;
public $weight;
public $sex;
function __construct($name,$age,$weight,$sex)
{
$this->name=$name;
$this->age=$age;
? ? ? ? $this->weight=$weight;
$this->sex=$sex;
}
public function showme(){
echo '這個應該不顯示';
}
}
class basketball extends SportObject
{
function __construct($name,$height)
{
$this->name=$name;
$this->height=$height;
}
}
? function showme(){
if ($this->height>=175) {
return $this->name.",符合打籃球";
} else{
return $this->name.",不符合";
}
}
class weightlift extends SportObject
{
function showme(){
if ($this->weight<85) {
return $this->name.",符合舉重";
} else {
return $this->name.",不符合";
}
}
}
$ming = new basketball('小明','160');
echo $ming->showme();
$fang = new weightlift('小方','10','100','男');
echo $fang->showme();
?>