2010年3月24日
摘要: using System; using System.Collections.Generic; using System.Text; namespace Delegate { // 热水器 public class Heater { private int temperature; public string type = “RealFire 001″; // 添... 阅读全文
posted @ 2010-03-24 21:14 凯===凯 阅读(391) 评论(1) 推荐(1) 编辑
摘要: 下面代码是使用C#实现观察者模式的例子: //“观察者”接口 public interface IObserver { void Notify(object anObject); } //“被观察对象”接口 public interface IObservable { void Register(IObserver anObserver); ... 阅读全文
posted @ 2010-03-24 21:11 凯===凯 阅读(3227) 评论(1) 推荐(0) 编辑
摘要: 一、 观察者模式 目的 概述 原理 二、 C#中的观察者模式 概述 模型与观察者基类 优点 三、 事例 题目:猫大叫,两只老鼠开始逃跑,主人醒来,宝宝也醒来了并且哭了起来 解决方案: 1. 建立模型(目标基类) 2. 建立观察者基类(单行为,多行为) 3. 建立具体目标 4. 建立具体观察者 5. 运行测试 一、 观察者模式 目的 我们都知道解决一个问题有N种解决方式,但在面向对象... 阅读全文
posted @ 2010-03-24 21:09 凯===凯 阅读(1638) 评论(0) 推荐(0) 编辑