2012年6月8日
摘要: 状态模式:允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类。以下是例子: public interface Weather { String getWeather(); } public class Rain implements Weather { public String getWeather() { return "下雨"; } } public class Sunshine implements Weather { public String getWeather() { return "阳光"; } } public clas 阅读全文
posted @ 2012-06-08 16:55 lee0oo0 阅读(197) 评论(0) 推荐(0)
摘要: 迭代模式:给定一个语言,定义它的文法的一种表示,并定义一个解释器,这个解释器使用该表示来解释语言中的句子。以下是例子: public interface Iterator { Object next(); void first(); void last(); boolean hasNext(); } public class IteratorImpl implements Iterator{ private List list; private int index; public IteratorImpl(List list){ inde... 阅读全文
posted @ 2012-06-08 16:37 lee0oo0 阅读(281) 评论(0) 推荐(0)