亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

小明的方法為什么不能覆蓋父類?


<?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();

?>


正在回答

舉報

0/150
提交
取消

小明的方法為什么不能覆蓋父類?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號