php 对象适配器模式
来源:互联网 发布:电影推荐算法数据集 编辑:程序博客网 时间:2024/04/26 02:09
/** *对象适配器模式 *@author li.yonghuan *@version 2014.02.13 *//** *目标角色 *@author li.yonghuan *@version 2014.02.13 */interface Target { /** *源类也有的方法1 */ public function sampleMethod1(); /** *源类没有的方法2 * */ public function sampleMethod2();}/** *源角色 *@author li.yonghuan *@version 2014.02.13 */class Adaptee { /** *方法1 * */ public function sampleMethod1() { echo 'Adaptee sampleMethod1 <br/>'; }}/** *类适配器角色 *@author li.yonghuan *@version 2014.02.13 */class Adapter implements Target { /** *adaptee *@var object Adaptee */ private $adaptee; /** *构造方法 *@param $adaptee Adaptee * */ public function __construct( Adaptee $adaptee ) { $this->adaptee = $adaptee; } /** *方法1 * */ public function sampleMethod1() { $this->adaptee->sampleMethod1(); } /** *方法2 */ public function sampleMethod2() { echo 'Adapter sampleMethod2 <br/>'; }}/** *客户端调用 */class Client { /** *main program * */ public static function main() { $adaptee = new Adaptee(); $adapter = new Adapter( $adaptee ); $adapter->sampleMethod1(); $adapter->sampleMethod2(); }}Client::main();
0 0
- php 对象适配器模式
- 适配器模式(对象适配器)
- 适配器模式-对象适配器
- 适配器模式之对象适配器
- 适配器模式:类适配器和对象适配器
- 对象适配器模式相关
- 对象适配器模式
- 对象适配器模式学习
- 对象适配器模式
- php实现适配器模式
- php实现适配器模式
- php 适配器模式
- php 适配器模式
- 9.php适配器模式
- php适配器模式
- PHP适配器模式
- 适配器模式-PHP
- php适配器模式
- Hacking EV3系列之六:iOS使用Direct Command 控制EV3
- BOIS中功能小知识
- 小公司如何组建团队
- Vsftp设置为PASV mode(被动模式传送)
- maven项目出现红色感叹号
- php 对象适配器模式
- c语言函数中参数argc和argv是什么意思?
- session和cookie的区别
- 【机器学习——K最邻近算法】
- 斗地主算法(4)
- UML之构件图和部署图
- 简单工厂、工厂方法模式和抽象工厂模式的分析
- hdu3038
- 程序猿群19377500,招纳IT精英