国产探花免费观看_亚洲丰满少妇自慰呻吟_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();

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 洮南市| 闽侯县| 运城市| 五大连池市| 昌平区| 遵义市| 全南县| 伊宁县| 马山县| 昌都县| 哈密市| 宝鸡市| 平利县| 罗定市| 天津市| 潜江市| 汪清县| 长武县| 勃利县| 望谟县| 神池县| 温州市| 四川省| 海盐县| 临湘市| 锦屏县| 小金县| 阿瓦提县| 合作市| 扬中市| 烟台市| 邵阳市| 阿坝县| 湖北省| 友谊县| 荥阳市| 福泉市| 雅安市| 武威市| 鄂托克旗| 凤翔县|