国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php設計模式 Bridge (橋接模式)

2024-05-04 23:18:10
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


<?php
/**
* 橋接模式
*
* 將抽象部份與它實現部分分離,使用它們都可以有獨立的變化
*/
abstract class Implementor
{
abstract public function operation();
}
class ConcreteImplementorA extends Implementor
{
public function operation()
{
echo "ConcreteImplementorA Operation<br/>";
}
}
class ConcreteImplementorB extends Implementor
{
public function operation()
{
echo "ConcreteImplementorB Operation<br/>";
}
}
class Abstraction
{
protected $_implementor = null;
public function setImplementor($implementor)
{
$this->_implementor = $implementor;
}
public function operation()
{
$this->_implementor->operation();
}
}
class RefinedAbstraction extends Abstraction
{
}
class ExampleAbstraction extends Abstraction
{
}
//
$objRAbstraction = new RefinedAbstraction();
$objRAbstraction->setImplementor(new ConcreteImplementorB());
$objRAbstraction->operation();
$objRAbstraction->setImplementor(new ConcreteImplementorA());
$objRAbstraction->operation();
$objEAbstraction = new ExampleAbstraction();
$objEAbstraction->setImplementor(new ConcreteImplementorB());
$objEAbstraction->operation();

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大石桥市| 定结县| 满城县| 公安县| 利辛县| 海安县| 额尔古纳市| 曲松县| 会泽县| 逊克县| 尤溪县| 濮阳市| 广宁县| 安塞县| 开鲁县| 谷城县| 灵川县| 宾阳县| 凌云县| 台州市| 靖边县| 厦门市| 天气| 耒阳市| 依兰县| 来凤县| 屯门区| 南昌县| 西平县| 保靖县| 金川县| 怀集县| 灌南县| 喀什市| 长沙县| 科技| 启东市| 霍邱县| 色达县| 中西区| 东乌|