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

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

博客园 - Love Fendi

性能优化系列---查询高cup的sql 8.17--8.24积累 sql server 2005 analysis service step by step(三):创建父子维度 sql server 2005 analysis service step by step(二):创建时间维度 sql serve 2005 analysis service step by step(一):创建标准维度 算法练习五:求数组中第k大的数 算法练习四:求N!不溢出 算法练习三:奇偶分割 算法练习二:二分查找 数据库锁 算法练习一:最大公约数与最小公倍数 索引优化 生成验证码,同时异步获取加密后的验证码 自定义控件中与脚本资源集成的若干处理方式 一条语句删除表中某字段重复的数据 动态按需异步加载js文件 在Nhibernate中使用Json.net中出现Self referencing loop的错误的处理 JQuery学习笔记 c#委托事件 入门
State模式学习
Love Fendi · 2009-11-01 · via 博客园 - Love Fendi

enum DocumentState
{
    readonly,Editable
}


class Document
{
 DocumentState state;
 public void Handle()
 {
  if(state=DocumentState.readonly)
  {
  }
  else
  {
  }
 }
}
-------------------------------------
abstract clasass StatedDocument  ---表达状态及依赖的行为
{
 public abstract void Handle1()
 public abstract void Handle2()
 public abstract void Handle3()
 public abstract StatedDocument Next
        { get;set;}
}

class Document------Request
{
 StatedDocument statedDocument;
 public void SetStatedDocument(StatedDocument statedDocument)
 {
  this.statedDocument=statedDocument;
 }
 public void Handle1()
 {
  statedDocument.Handle1();
 }
 public void Handle2()
 {
  statedDocument.Handle2();
 }
 public void Handle3()
 {
  statedDocument.Handle3();
 }
}

-----------具体的状态类

public class ReadOnlyDocumentState:StatedDocument 

{

   public abstract void Handle1()--------edit button

      {

      system.println(" system is readonly");

      SetStatedDocument(new EditableDocumentState)

      }

}