摘要: 代码实现 /** * 源发器类 * @author bzhx * 2017年3月15日 */ public class Emp { private String ename; private int age; private double salary; //备忘操作,并返回备忘录对象 public 阅读全文
posted @ 2017-09-05 13:37 皈依之路 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 代码实现1 public interface Observer { void update(Subject subject); } public class ObserverA implements Observer{ private int myState; //myState需要跟目标对象的st 阅读全文
posted @ 2017-09-05 13:26 皈依之路 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 代码实现 public interface State { void handle(); } /** * 空闲状态 * @author bzhx * 2017年3月15日 */ public class FreeState implements State{ @Override public voi 阅读全文
posted @ 2017-09-05 13:11 皈依之路 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 代码实现 public abstract class BankTemplateMethod { //具体方法 public void takeNumber(){ System.out.println("取号排队"); } public abstract void transact(); //办理具体 阅读全文
posted @ 2017-09-05 13:06 皈依之路 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 代码实现 public interface Strategy { public double getPrice(double standardPrice); } public class NewCustomerFewStrategy implements Strategy{ @Override pu 阅读全文
posted @ 2017-09-05 13:01 皈依之路 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-09-05 12:54 皈依之路 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-09-05 12:53 皈依之路 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 介绍 角色 使用场景 代码实现 public interface Command { //这个方法是一个返回结果为空的方法 //实际项目中,可以根据需求设计多个不同的方法 void execute(); } class ConcreteCommand implements Command{ priv 阅读全文
posted @ 2017-09-05 12:50 皈依之路 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 代码实现 public interface Mediator { void register(String dname,Department d); void command(String dname); } /* * 同事类接口 */ public interface Department { v 阅读全文
posted @ 2017-09-05 12:01 皈依之路 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 代码实现 public interface MyIterator { void first(); //将游标指向第一个元素 void next(); //将游标指向下一个元素 boolean hasNext(); //判断是否存在下一个元素 boolean isFirst(); boolean is 阅读全文
posted @ 2017-09-05 11:50 皈依之路 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 后面我们将学习设计模式里面的行为型模式 代码实现 /** * 抽象类 * @author bzhx * 2017年3月14日 */ public abstract class Leader { protected String name; protected Leader nextLeader; / 阅读全文
posted @ 2017-09-05 11:42 皈依之路 阅读(235) 评论(0) 推荐(0) 编辑