The main application scenario of the appearance mode is to provide a simple interface for the complex subsystem and improve the independence of the subsystem.
To create the Drawerone class:
Package Facade;public class Drawerone {public void open () {System.out.println ("first drawer opened"); GetKey ();} public void GetKey () {System.out.println ("Get the key of the first drawer");}}
To create the Drawertwo class:
Package Facade;public class Drawertwo {public void open () {System.out.println ("second drawer opened"); GetFile ();} public void GetFile () {System.out.println ("Get this important file");}}
Observation class:
Package Facade;public class Drawerfacade {drawerone Darwerone = new Drawerone ();D rawertwo darwertwo = new Drawertwo ();p UBL IC void Open () {Darwerone.open ();d arwertwo.open ();}}
Under test, this test class uses the Drawerfacade class uniformly to invoke other subsystem class functions
Package Facade;public class Test {public static void main (string[] args) {Drawerfacade drawer = new Drawerfacade ();d rawer. Open ();}}
Results:
The first drawer was opened to get the key to the first drawer the second drawer was opened to get this important file
Java design mode----appearance mode