1 外观模式
隐藏系统的复杂性,并向客户端提供了一个客户端可以访问系统的接口
2 类图
3 测试代码
1) 接口:Person.java文件
public interface Person { void info(); }
2)Man.java
public class Man implements Persion{ @Override public void info() { System.out.println("hello man"); } }
3) Woman.java
public class Woman implements Persion{ @Override public void info() { System.out.println("hello woman "); } }
4) PersonMaker.java
public class PsersonMaker { private Man man; private Woman woman; public ShapeMaker() { man= new Man(); woman= new Woman(); } public void manInfo(){ man.info(); } public void womanInfo(){ woman.info(); } }
测试代码如下:
public class FacadePatternDemo { public static void main(String[] args) { PersonMaker persionMaker = new persionMaker(); persionMaker.manInfo(); persionMaker.womanInfo(); } }
4 实现效果
hello man hello woman