设计模式---翻译器模式
来源:互联网 发布:linux pptp server 编辑:程序博客网 时间:2024/05/17 07:41
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApplication1
- {
- abstract class Expretion
- {
- public void Translate(Words w)
- {
- string s = w.MyWords.Substring(0, 1);
- w.MyWords = w.MyWords.Substring(2);
- Excute(s);
- }
- public abstract void Excute(string s);
- }
- class EnglishExpretion:Expretion
- {
- public override void Excute(string s)
- {
- switch (s)
- {
- case "e":
- Console.WriteLine("对方说的英语");
- break;
- }
- }
- }
- class GermanExpretion:Expretion
- {
- public override void Excute(string s)
- {
- switch (s)
- {
- case "g":
- Console.WriteLine("对方说的德语");
- break;
- }
- }
- }
- class Words
- {
- private string words;
- public string MyWords
- {
- get
- {
- return words;
- }
- set
- {
- words = value;
- }
- }
- }
- class Client
- {
- public static void Main()
- {
- Words w = new Words();
- w.MyWords = "e g e e g ";
- Expretion e=null;
- while (w.MyWords.Length>0)
- {
- switch (w.MyWords.Substring(0,1))
- {
- case "e":
- e = new EnglishExpretion();
- break;
- case"g":
- e = new GermanExpretion();
- break;
- }
- e.Translate(w);
- }
- Console.Read();
- }
- }
- }
- 设计模式---翻译器模式
- 翻译器
- 设计模式----Bridge模式
- 设计模式---Adapter模式
- 模式设计:观察者模式
- 设计模式------工厂模式
- 设计模式------工厂模式
- 设计模式 command模式
- [设计模式]Factory模式
- 行为模式设计模式
- 设计模式-----Singleton模式
- 设计模式------Factory 模式
- 设计模式-Singleton模式
- 设计模式 [ 工厂模式 ]
- 设计模式---装饰模式
- 设计模式-----观察者模式
- 设计模式--工厂模式
- 设计模式--外观模式
- [原创]x.509证书在WCF中的应用(CS篇)
- Essential SharePoint
- 2008-8-20
- Teach Yourself Microsoft SharePoint 2003 in 10 Minutes
- Patterns for effective use cases
- 设计模式---翻译器模式
- 手机探索者开发实录—MobileExplorer接口
- Software Engineering and Computer Games
- Effective Java: programming language guide
- Pragmatic Project Automation: How to Build, Deploy, and Monitor Java Apps
- 关于显式接口实现
- UML for Java Programmers
- Linux下的aMule设置
- Eclipse distilled