博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
interface -- 接口类
阅读量:6915 次
发布时间:2019-06-27

本文共 752 字,大约阅读时间需要 2 分钟。

getMaximumSpeed();//150 echo '
'; class Street extends FastCar {protected $speedLimit;protected $cars; public function __construct($speedLimit = 200) {$this->cars = array(); //初始化变量$this->speedLimit = $speedLimit;} function isStreetLegal($car) {if($car instanceof ISpeedInfo) {if($car->getMaximumSpeed() < $this->speedLimit) {return true;} else {return false;}} else {//扩展类必须实现ISpeedInfo才能使street合法return false;}} public function addCar($car) {if($this->isStreeLegal($car)) {echo 'The Car was allowed on the road.';$this->cars[] = $car;} else {echo 'The Car is too fast and was not allowed on the road.';}} } /* class Street extends FastCar{} */ $a = new Street(); echo $a->getMaximumSpeed(); //150

 

转载于:https://www.cnblogs.com/yhdsir/p/4649065.html

你可能感兴趣的文章
新年快乐,介绍个简单的Excel理财工作的制作方法
查看>>
[翻译-ASP.NET MVC]Contact Manager开发之旅之迭代1 - 创建Contact Manager应用
查看>>
Linux C 下使用openssl 进行SHA1加密
查看>>
4星|《我的第一本创业融资指南》:投资人写的创业者融资指南
查看>>
再现一分钱中标,中国电信拿下海南政务云项目
查看>>
文件服务器之二:FTP服务器(pureftp)
查看>>
30分钟快速搭建门店智能监控视频分析
查看>>
解决drbd不能启动问题(Can not load the drbd module.)
查看>>
简单的RIP实验
查看>>
4星|《哈佛商业评论》2017年11期:高质量基础管理对企业的重要性不亚于卓越的战略思考。...
查看>>
ssh端口转发(之kettle ssh方式连接数据库)
查看>>
出现错误,显示事务没有回滚
查看>>
2、权限、变量、for 学习笔记
查看>>
Centos6安装配置rsync+inotify实时单向同步
查看>>
Cisco系列路由器密码恢复研究与实践
查看>>
顺时针打印矩阵
查看>>
Linux 2 unit5 LVM创建
查看>>
函数定义、函数的参数、函数的默认参数
查看>>
javaScript显示和隐藏(display属性)
查看>>
采用管道进行通讯的例子
查看>>