色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

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

復制代碼 代碼如下:
<?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();

php技術php設計模式 Bridge (橋接模式),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 环江| 厦门市| 陆丰市| 青浦区| 宜宾市| 翼城县| 贵南县| 昌吉市| 镇原县| 深州市| 景泰县| 夏河县| 镇远县| 缙云县| 湖南省| 印江| 武乡县| 长海县| 咸宁市| 大渡口区| 襄城县| 宣汉县| 正阳县| 崇阳县| 乾安县| 河北省| 连平县| 崇义县| 北京市| 松溪县| 广安市| 北票市| 定陶县| 广河县| 桦甸市| 鸡泽县| 朝阳市| 巴林右旗| 奉新县| 鄂伦春自治旗| 衡阳市|