c#设计模式之桥接模式
来源:互联网 发布:我的世界手机java版 编辑:程序博客网 时间:2024/05/17 00:10
using System;class Color{ public string color;}class Red:Color{ public Red() { this.color = "red"; }}class Green:Color{ public Green() { this.color = "green"; }}class Blue:Color{ public Blue() { this.color = "blue"; }}abstract class Brush{ protected Color c; public abstract void Paint(); public void SetColor(Color c) { this.c = c; }}class BigBrush:Brush{ public override void Paint() { Console.WriteLine("BigBrush {0}",c.color); }}class SmallBrush:Brush{ public override void Paint() { Console.WriteLine("SmallBrush {0}",c.color); }}class Program{ public static void Main() { Brush b = new BigBrush(); b.SetColor(new Red()); b.Paint(); b.SetColor(new Green()); b.Paint(); Brush a = new SmallBrush(); a.SetColor(new Red()); a.Paint(); a.SetColor(new Blue()); a.Paint(); Console.ReadKey(); }}
阅读全文
0 0
- C# 设计模式 之 桥接模式
- c#设计模式之[桥接模式]
- C# 设计模式之桥接模式
- c#设计模式之桥接模式
- C#设计模式之桥接
- C#设计模式之8——桥接模式
- C#设计模式之桥接模式(Bridge Pattern)
- C#设计模式之桥接模式(Bridge Pattern)
- C#设计模式07-桥接模式
- 【C#设计模式-桥接模式】
- C#设计模式—桥接模式
- C#设计模式--桥接模式
- C#设计模式之Observer设计模式(观察者设计模式)
- C# 设计模式 之 适配器模式(Adapter)
- C# 设计模式 之 抽象工厂模式
- C# 设计模式之生成器模式
- C# 设计模式之单件模式
- C# 设计模式之观察者模式
- 1. Java EE简介
- utf-8编码
- Bayesian formula
- Shape 类型属性参数全解
- Activiti流程定义查询
- c#设计模式之桥接模式
- 【OPNET学习系列文章之6】建立路由表
- 优化器及自动化调超参数
- Classification and logistic regression离散型:分类问题
- 二进制与十六进制相互转换
- Professional JS(三.Language basic-syntax&keywords&reserved&variables&half data type)&黑画(5)
- 在 Laravel 的 Blade 模版中定义变量
- centos 下修改用户密码
- halcon学习笔记——Image,region,xld初步