标签:
<?php
header(‘content-type:text/html;charset=utf-8‘);
class ZiXingChe{
protected $name;
protected $gulu = 2;
protected $chezuo = 1;
protected $jiaodeng = 2;
protected $yanse;
public function __construct($name){
$this->name = $name;
}
public function qixing(){
echo ‘可以骑行‘;
}
public function shache(){
echo ‘可以刹车‘;
}
public function shuoming(){
echo $this->name;
echo ‘,‘;
$this->qixing();
echo ‘,‘;
$this->shache();
}
}
class ZheDieZiXingChe extends ZiXingChe{
// public function __construct(){
//
// }
public function zhedie(){
echo ‘可以折叠‘;
}
public function shuoming(){
echo $this->name;
echo ‘,‘;
$this->qixing();
echo ‘,‘;
$this->shache();
echo ‘,‘;
$this->zhedie();
}
}
class DianDongZiXingChe extends ZiXingChe{
private $dianchi = 1;
public function diandongxingshi(){
echo ‘电动行驶‘;
}
public function shuoming(){
echo $this->name;
echo ‘,‘;
$this->qixing();
echo ‘,‘;
$this->shache();
echo ‘,‘;
$this->diandongxingshi();
}
}
$putong = new ZiXingChe(‘普通型自行车‘);
$putong->shuoming();
echo ‘<br><br>‘;
$zhedie = new ZheDieZiXingChe(‘折叠自行车‘);
$zhedie->shuoming();
echo ‘<br><br>‘;
$diandong = new DianDongZiXingChe(‘电动自行车‘);
$diandong->shuoming();
?>
标签:
原文地址:http://www.cnblogs.com/kulowreidyql/p/5604825.html