其他
漫画:设计模式之 “外观模式”
The following article is from 程序员小灰 Author 小灰
public class SubSystemA {
public void methodA(){
System.out.println("执行方法A");
}
public void comboMethodA(){
SubSystemA subSystemA = new SubSystemA();
SubSystemB subSystemB = new SubSystemB();
SubSystemD subSystemD = new SubSystemD();
subSystemA.methodA();
subSystemB.methodB();
subSystemD.methodD();
}
public void comboMethodB(){
SubSystemE subSystemE = new SubSystemE();
SubSystemD subSystemD = new SubSystemD();
SubSystemB subSystemB = new SubSystemB();
subSystemE.methodE();
subSystemD.methodD();
subSystemB.methodB();
}
}
public class Client {
public static void main(String[] args) {
Facade facade = new Facade();
//通过外观模式,调用组合接口A
facade.comboMethodA();
//通过外观模式,调用组合接口B
facade.comboMethodB();
}
}
更多精彩推荐