zoukankan      html  css  js  c++  java
  • 设计模式学习笔记--桥接模式

     1 using System;
     2 
     3 namespace Bridge
     4 {
     5     /// <summary> 
     6     /// 作者:bzyzhang
     7     /// 时间:2016/5/31 7:19:03 
     8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
     9     /// Implementor说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
    10     /// </summary> 
    11     public abstract class Implementor
    12     {
    13         public abstract void Operation();
    14     }
    15 }
    View Code
     1 using System;
     2 
     3 namespace Bridge
     4 {
     5     /// <summary> 
     6     /// 作者:bzyzhang
     7     /// 时间:2016/5/31 7:20:35 
     8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
     9     /// ConcreteImplementorA说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
    10     /// </summary> 
    11     public class ConcreteImplementorA:Implementor
    12     {
    13         public override void Operation()
    14         {
    15             Console.WriteLine("具体实现A的方法执行");
    16         }
    17     }
    18 }
    View Code
     1 using System;
     2 
     3 namespace Bridge
     4 {
     5     /// <summary> 
     6     /// 作者:bzyzhang
     7     /// 时间:2016/5/31 7:21:25 
     8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
     9     /// ConcreteImplementorB说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
    10     /// </summary> 
    11     public class ConcreteImplementorB:Implementor
    12     {
    13         public override void Operation()
    14         {
    15             Console.WriteLine("具体实现B的方法执行");
    16         }
    17     }
    18 }
    View Code
     1 using System;
     2 
     3 namespace Bridge
     4 {
     5     /// <summary> 
     6     /// 作者:bzyzhang
     7     /// 时间:2016/5/31 7:22:21 
     8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
     9     /// Abstraction说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
    10     /// </summary> 
    11     public abstract class Abstraction
    12     {
    13         protected Implementor implementor;
    14 
    15         public void SetImplementor(Implementor implementor)
    16         {
    17             this.implementor = implementor;
    18         }
    19 
    20         public virtual void Operation()
    21         {
    22             implementor.Operation();
    23         }
    24     }
    25 }
    View Code
     1 using System;
     2 
     3 namespace Bridge
     4 {
     5     /// <summary> 
     6     /// 作者:bzyzhang
     7     /// 时间:2016/5/31 7:24:16 
     8     /// 博客地址:http://www.cnblogs.com/bzyzhang/
     9     /// RefinedAbstraction说明:本代码版权归bzyzhang所有,使用时必须带上bzyzhang博客地址 
    10     /// </summary> 
    11     public class RefinedAbstraction:Abstraction
    12     {
    13         public override void Operation()
    14         {
    15             implementor.Operation();
    16         }
    17     }
    18 }
    View Code
     1 namespace Bridge
     2 {
     3     class Program
     4     {
     5         static void Main(string[] args)
     6         {
     7             Abstraction ab = new RefinedAbstraction();
     8 
     9             ab.SetImplementor(new ConcreteImplementorA());
    10             ab.Operation();
    11 
    12             ab.SetImplementor(new ConcreteImplementorB());
    13             ab.Operation();
    14         }
    15     }
    16 }
    View Code
  • 相关阅读:
    GDB调试汇编堆栈过程分析
    20145322 《信息安全系统设计基础》第十二周学习总结
    # 20145322《信息安全系统设计基础》第十一周学习总结
    20145322 《信息安全系统设计基础》第十周学习总结
    20145322学号 《信息安全系统设计基础》第9周学习总结(二)
    20145322学号 《信息安全系统设计基础》第9周学习总结(一)
    20145322 《信息安全系统设计基础》期中总结
    20145322 20145310 20145318信息安全系统设计基础实验报告
    20145322 《信息安全系统设计基础》第8周学习总结
    《信息安全系统设计基础》实验一报告
  • 原文地址:https://www.cnblogs.com/bzyzhang/p/5544611.html
Copyright © 2011-2022 走看看