General description: understanding of the builder Mode

Source: Internet
Author: User

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.
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.