2015年4月2日

java中23种设计模式之18-原型模式(Prototype pattern)

摘要: class Something{ public String something=null;}class Prototype implements Cloneable{ private String name; public Something aSomething=new Something();... 阅读全文

posted @ 2015-04-02 20:50 wudymand 阅读(130) 评论(0) 推荐(0) 编辑

java中23种设计模式之17-状态模式(state pattern)

摘要: interface State{ public void handle(StateMachine statemachine);}class Eat implements State{ StateMachine statemachine=null; public void handle(StateMa... 阅读全文

posted @ 2015-04-02 20:49 wudymand 阅读(124) 评论(0) 推荐(0) 编辑

java中23种设计模式之16-访问者模式(visitor pattern)

摘要: import java.util.ArrayList;import java.util.List;abstract class IVisitor{ public abstract void visit(Banana banana); public abstract void visit(Rice ... 阅读全文

posted @ 2015-04-02 20:48 wudymand 阅读(123) 评论(0) 推荐(0) 编辑

java中23种设计模式之15-责任链模式(ChainOfResponsibility pattern)

摘要: interface Vacation{ public void requestVacation(int days);}class Clerk implements Vacation{ private int days; public void requestVacation(int days) { ... 阅读全文

posted @ 2015-04-02 20:47 wudymand 阅读(147) 评论(0) 推荐(0) 编辑

java中23种设计模式之14-观察者模式(observer pattern)

摘要: import java.util.ArrayList;interface Watcher{ void update(String string);}class ConcreteWatcher implements Watcher{ private String name=null; public C... 阅读全文

posted @ 2015-04-02 20:46 wudymand 阅读(120) 评论(0) 推荐(0) 编辑

java中23种设计模式之13-组合模式(composite pattern)

摘要: import java.util.LinkedList;abstract class Company{ private String name; public void setName(String name) { this.name=name; } public String getName()... 阅读全文

posted @ 2015-04-02 20:45 wudymand 阅读(135) 评论(0) 推荐(0) 编辑

java中23种设计模式之12-装饰模式(decorator pattern)

摘要: class Girl{ public void showAppearance() { System.out.println("the girl: face without make up"); } }class TakeFlower extends Girl{ Girl girl=null; pu... 阅读全文

posted @ 2015-04-02 20:43 wudymand 阅读(158) 评论(0) 推荐(0) 编辑

导航