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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
C
Cisco Blogs
A
Arctic Wolf
月光博客
月光博客
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
量子位
小众软件
小众软件
Latest news
Latest news
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
N
Netflix TechBlog - Medium
K
Kaspersky official blog
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Y
Y Combinator Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Schneier on Security
D
Docker
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
GbyAI
GbyAI
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
H
Help Net Security
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tenable Blog
B
Blog
Know Your Adversary
Know Your Adversary
IT之家
IT之家

博客园 - 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 类的行为啊,期待高手解答啊