php-设计模式-模板方法模式
来源:互联网 发布:武功知乎 编辑:程序博客网 时间:2024/06/02 06:59
abstract class Journey { final public function takeATrip() { $this->buyAFlight(); $this->takePlane(); $this->enjoyVacation();//!!! $this->buyGift(); $this->takePlane(); } //key feature abstract protected function enjoyVacation(); //optional. protected function buyGift() { } /** * This method will be unknown by subclasses (better) */ private function buyAFlight() { echo "Buying a flight\n"; } final protected function takePlane() { echo "Taking the plane\n"; }}class CityJourney extends Journey { protected function enjoyVacation() { echo "Eat, drink, take photos and sleep\n"; }}class BeachJourney extends Journey{ protected function enjoyVacation() { echo "Swimming and sun-bathing\n"; }}$journey = new BeachJourney();$journey->takeATrip();//Buying a flight//Taking the plane//Swimming and sun-bathing$journey = new CityJourney();$journey->takeATrip();
0 0
- php-设计模式-模板方法模式
- PHP设计模式-模板模式(模板方法模式)
- PHP设计模式-模板模式(模板方法模式)
- Php设计模式之【模板方法模式Template Method Pattern 】
- PHP草根论之设计模式-模板方法模式
- 设计模式入门-模板方法模式(php版)
- 模板方法模式(学习于 php设计模式 书 )
- PHP设计模式系列(六):模板方法模式
- PHP 模板方法模式
- 设计模式:模板方法模式
- 设计模式 - 模板方法模式
- 设计模式:模板方法模式
- 设计模式 模板方法模式
- 设计模式--模板方法模式
- 设计模式-【模板方法模式】
- 设计模式: 模板方法模式
- 设计模式- 模板方法模式
- 设计模式 - 模板方法模式
- C/C++开源项目中的100个Bugs
- oracle手动创建awk报告的方法
- javaweb项目大数据处理的解决方案
- WPF多语言
- IOS学习网站汇总
- php-设计模式-模板方法模式
- 负载均衡、LVS概述
- easyui validatebox 验证集合
- QT下的UDP通讯
- 双向循环链表设计分析之五
- turtlebot学习记录for ros
- VC6.0不兼容win8/8.1等新系统的结局方案
- php插入mysql的中文乱码问题
- Python:第四天