zoukankan      html  css  js  c++  java
  • 桥接模式

    桥接模式:将抽象部分与它的实现部分分离,使它们都可以独立的变化.

    <?php
    /**
    * Created by PhpStorm.
    * User: Administrator
    * Date: 2018/2/28
    * Time: 10:45
    */

    namespace frontendmodels;


    abstract class Implementor
    {

    public abstract function Operation();

    }




    class ConcreteImplementorA  extends Implementor
    {

    public function Operation()
    {
    echo "实现方法A"."<br>";
    }

    }




    <?php
    /**
    * Created by PhpStorm.
    * User: Administrator
    * Date: 2018/2/28
    * Time: 10:47
    */

    namespace frontendmodels;


    class ConcreteImplementorB extends Implementor
    {

    public function Operation()
    {
    echo "B类实现方法"."<br>";
    }

    }



    <?php
    /**
    * Created by PhpStorm.
    * User: Administrator
    * Date: 2018/2/28
    * Time: 10:48
    */

    namespace frontendmodels;


    class Abstraction
    {

    private $implementor;

    public function __construct($implementor)
    {
    $this->implementor = $implementor;
    }

    public function Operation(){

    $this->implementor->Operation();

    }
    }





    $abstraction = new Abstraction(new ConcreteImplementorA());

    $abstraction->Operation();


    $abstraction = new Abstraction(new ConcreteImplementorB());

    $abstraction->Operation();


  • 相关阅读:
    文本溢出隐藏与定位
    css基本属性 内边距 外边距及盒模型
    CSS基本属性2
    CSS基本属性
    CSS入门
    表格与表单
    列表与图片
    html标签类型
    HashMap和HashTable
    Map接口
  • 原文地址:https://www.cnblogs.com/paulversion/p/8482417.html
Copyright © 2011-2022 走看看