Simply put, it seems that I want a house to live in, but I don't know how to build it (simple wall building, low level) or how to design it (building several rooms, A few nice-looking, high-level), so I need to find a group of migrant workers who will build walls and have to find a designer who knows how to design them. I also want to ensure that migrant workers listen to the designer's leadership, the designers themselves do not work either. They just run the command to build a wall and a door here, so that the migrant workers can start construction. Finally, I can ask the migrant workers for a house. In this process, there is nothing for a designer, except for his design and command in his mind, so the house is also required for migrant workers. Remember!
Just like a lot of domestic enterprises that use ERP, the first thing they need to do is find a software company. After finding a software company, the software company said that I only know how to write software and how to implement it, the entire ERP process is unclear. Well, we have to look for a consulting company. Well, after we find Deloitte, Deloitte says, "How do I do software, I can guarantee that the software can provide you with an ERP system.
This mode is used to decouple the design and construction without interfering with each other.
Public Interface Builder
{
Public Void Makewindow ();
Public Void Makefloor ();
Public Room getroom ();
}
/** **************************************** ****************** */
Package Builder;
Public Class Designer {
Public Designer (){
}
Public Void Order (Builder)
{
Builder. makewindow ();
Builder. makefloor ();
}
}
/** **************************************** ****************** */
Package Builder;
Public Class Mingong Implements Builder {
Private String window = "";
Private String floor = "";
Public Mingong (){
}
Public Void Makewindow (){
Window = New String ("window ");
}
Public Void Makefloor (){
Floor = New String ("floor ");
}
Public Room getroom ()
{
If ((! Window. Equals (""))&&(! Floor. Equals ("")))
{
Room r = New Room ();
R. setfloor (floor );
R. setwindow (window );
Return R;
}
Else Return Null ;
}
}
/** **************************************** ****************** */
Package Builder;
Public Class Room {
Private String window = "";
Private String floor = "";
Public Room (){
}
Public String getfloor (){
Return Floor;
}
Public Void Setfloor (string floor ){
This . Floor = floor;
}
Public String getwindow (){
Return Window;
}
Public Void Setwindow (string window ){
This . Window = window;
}
}
/** **************************************** ****************** */
Package Builder;
Public Class Client {
Public Client (){
}
Public Static Void Main (string [] ARGs ){
Builder mingong = New Mingong ();
Designer designer = New Designer ();
Designer. Order (mingong );
Room r = mingong. getroom ();
System. Out. println (R. getwindow ); // The window is output, indicating that the build is successful.
}
}