Java 设计模式_外观设计(简单了解)

2019-07-13 22:41发布

public class User { public void saloon(){ System.out.println("客厅电源"); } public void bedroom(){ System.out.println("卧室电源"); } public void toilet(){ System.out.println("厕所电源"); } } public class Swiitch { public void money(User user){ user.bedroom(); user.toilet(); user.saloon(); } }
public class Test { public static void main(String[] args) { User user = new User(); Swiitch sw=new Swiitch(); sw.money(user); } }