1.中介者模式//自己不需要去协调之间的关系,由中介去维护
2.实例
public interface Mediator { void register(String dname,Department d); void command(String dname); } public class President implements Mediator { private Map<String,Department> map = new HashMap<String , Department>(); @Override public void command(String dname) { map.get(dname).selfAction(); } @Override public void register(String dname, Department d) { map.put(dname, d); } } public interface Department { void selfAction(); void outAction(); } public class Development implements Department { private Mediator m; public Development(Mediator m) { super(); this.m = m; m.register("development", this); } @Override public void outAction() { System.out.println("123"); } @Override public void selfAction() { System.out.println("456"); } } public class Client { public static void main(String[] args) { Mediator m = new President(); Market market = new Market(m); market.selfAction(); market.outAction(); } }