设计模式-门面模式

2022/2/24 23:55:17

本文主要是介绍设计模式-门面模式,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

public class System1 {
    public void dosomething() {
        System.out.println("system1..");
    }
}

public class System2 {
    public void dosomething() {
        System.out.println("system2..");
    }
}

public class Facade {
    System1 system1 = new System1();
    System2 system2 = new System2();
    public void dosomething() {
        system1.dosomething();
        system2.dosomething();
    }
}

public class Client1 {
    public static void main(String[] args) {
        Client1 client1 = new Client1();
        client1.dosomething();
    }

    public void dosomething() {
        Facade facade = new Facade();
        facade.dosomething();
    }
}

public class Client2 {
    public static void main(String[] args) {
        Client2 client2 = new Client2();
        client2.dosomething();
    }

    public void dosomething() {
        Facade facade = new Facade();
        facade.dosomething();
    }
}


这篇关于设计模式-门面模式的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程