1、Facade.java
package com.ssm.cts.pattern.facade; public class Facade { private ClassA a = new ClassA(); private ClassB b = new ClassB(); private ClassC c = new ClassC(); public void methodA(){ this.a.doSomethingA(); } public void methodB(){ this.b.doSomethingB(); } public void methodC(){ this.b.doSomethingB(); this.c.doSomethingC(); } }
2、ClassA.java
package com.ssm.cts.pattern.facade; public class ClassA { public void doSomethingA() { System.out.println("doSomethingA"); } }
3、ClassB.java
package com.ssm.cts.pattern.facade; public class ClassB { public void doSomethingB(){ System.out.println("doSomethingB"); } }
4、ClassC.java
package com.ssm.cts.pattern.facade; public class ClassC { public void doSomethingC(){ System.out.println("doSomethingC"); } }
5、Demo.java
package com.ssm.cts.pattern.facade; public class Demo { public static void main(String[] args) { Facade f = new Facade(); f.methodC(); } }