Correction status:qualified
Teacher's comments:
随着php教学的深入,我感觉越来余越深奥了,每天做作业的时间也更长了!敲得遍数更多了!加油
<?php spl_autoload_register(function ($ClassName){ require './class/'.$ClassName.'.php'; }); $road = new Point('清源路黄海路',4,12,true,false,true); echo '管理员:'.$road->admin().'<br>'; echo '路口名称:'.$road->roadName.'<br>'; echo '方向数:'.$road->direction.'<br>'; echo '车道数:'.$road->lane.'<br>'; echo '是否有抓拍机:'.($road->camera ? '有':'无').'<br>'; echo '是否有球机:'.($road->ball ? '有':'无').'<br>'; echo '是否有信号机:'.($road->signal ? '有':'无').'<br>';
点击 "运行实例" 按钮查看在线实例
<?php /医院 * Created by PhpStorm. * User: Administrator * Date: 2018/5/4 * Time: 17:26 */ class Road { protected $roadName = '';//路口名称 protected $direction = 0;//方向数 protected $lane = 0;//车道数 function __construct($roadName,$direction,$lane) { $this->roadName = $roadName; $this->direction = $direction; $this->lane = $lane; } function admin() { return '周杰'; } }
点击 "运行实例" 按钮查看在线实例
<?php /医院 * Created by PhpStorm. * User: Administrator * Date: 2018/5/4 * Time: 17:29 */ class Point extends Road { private $camera = false; //是否有相机 private $ball = false; //是否有球机 private $signal = false; //是否有信号机 function __construct($roadName, $direction, $lane, $camera,$ball,$signal) { parent::__construct($roadName, $direction, $lane); $this->camera = $camera; $this->ball = $ball; $this->signal = $signal; } function __get($name) { return $this->$name; } function admin() { $admin = '张宏强,周杰'; return $admin; } }
点击 "运行实例" 按钮查看在线实例