惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
小众软件
小众软件
F
Fortinet All Blogs
博客园 - 叶小钗
博客园_首页
D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog

博客园 - tf.li

清理MVC4 Internaet 项目模板清理 SQL2014 尝试读取或写入受保护的内存。这通常指示其他内存已损坏 nodejs 环境配置技巧 mongdb window 服务安装批处理 bower 安装后 jade 引用404问题 我的Prototype模式框架 转自CnBeta 令人深思 [译稿]为什么我们不要 .NET 程序员 JSON.NET、WebService与JQuery协同工作 我修改的IP地址掩码 呵呵~~开心 Ext.Ajax.request 传值问题 从小做大之一---------一切从建模开始 [求助]关于文本行转列的疑问~~ To Terrylee 我的设计模型之小议工厂模式 我的设计模型之装饰者模式 我对线程池的一点理解 面向接口编程之惑 第二版 面向接口编程之惑 我的设计模型之简单工厂
我的设计模型之适配器模式
tf.li · 2008-07-01 · via 博客园 - tf.li

今天上午项目基本结束了 所以有时间学习一下设计模式了 在网上搜素了一下 好多关于这方面的文章 自己也是按照吕震宇大哥的Demo 写了一遍 力求理解 放代码

 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5
 6namespace 泡妞的故事
 7{
 8    class Program
 9    {
10        static void Main(string[] args)
11        {
12            Agreement ag = new Agreement();
13            Console.WriteLine("纪晓岚:老夫人,我们去读书了!");
14            Console.WriteLine("老夫人:乖,好好读呀!");
15            ag.Reading();
16            Console.WriteLine("纪晓岚:老夫人,我们去练字了!");
17            Console.WriteLine("老夫人:好呀好呀!");
18            ag.Writing();
19        }

20    }

21    class Girl
22    
23      public void  Eating()
24      {
25          Console.WriteLine("和姑娘吃东西啊");
26          Console.ReadLine();
27      }

28      public void Shopping()
29      {
30          Console.WriteLine("和姑娘吃购物啊");
31          Console.ReadLine();
32      }

33      public void Travelling()
34      {
35          Console.WriteLine("和姑娘吃游山玩水啊");
36          Console.ReadLine();
37      }

38    }

39    public interface Mother
40    {
41        void Reading();
42        void Writing();
43    }

44    public class Agreement : Mother
45    {
46        Girl girl = new Girl();
47        public void Reading()
48        {
49            girl.Eating();
50            girl.Shopping();
51        }

52        public void Writing()
53        {
54            girl.Travelling();
55        }

56    }

57
58}

59

不过最后我还是有一个问题 接口是用来做什么的呢 在这里 他并没有限制Agreement 类的行为啊,期待高手解答啊