为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用
package com.yl.demo.design;
public interface InterfaceA {
public void test();
}
package com.yl.demo.design;
public class InterfaceAImpl implements InterfaceA {
@Override
public void test() {
System.out.println("InterfaceA...");
}
}
package com.yl.demo.design;
public interface InterfaceB {
public void test();
}
package com.yl.demo.design;
public class InterfaceBImpl implements InterfaceB{
@Override
public void test() {
System.out.println("InterfaceB...");
}
}
package com.yl.demo.design;
public interface InterfaceC {
public void test();
}
package com.yl.demo.design;
public class InterfaceCImpl implements InterfaceC {
@Override
public void test() {
System.out.println("InterfaceC...");
}
}
package com.yl.demo.design;
public class Facade {
public void test() {
InterfaceA interfaceA = new InterfaceAImpl();
interfaceA.test();
InterfaceB interfaceB = new InterfaceBImpl();
interfaceB.test();
InterfaceC interfaceC = new InterfaceCImpl();
interfaceC.test();
}
}
package com.yl.demo.design;
public class test {
public static void main(String[] args) {
Facade facade = new Facade();
facade.test();
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/weixin_41359273/article/details/123319075
内容来源于网络,如有侵权,请联系作者删除!