To put it simply, I am a real estate developer who wants to build a villa, but I don't know how to build it (simple wall building, low level ), I also don't know how to design it (Building a few rooms, a few good-looking doors and a high level). So I need to find a civil engineer who will build walls and a designer who knows how to design it, I also want to ensure that the Migrant Workers listen to the leaders of designers, and the designers themselves do not work, just give commands, here build a wall, here build a door, so that the migrant workers start construction, finally, I can ask migrant workers for a house. In this process, there is nothing for a designer, except for the design and command in his mind, so the house is also required for migrant workers.
/// <Summary>
/// The work required to build a house
/// </Summary>
Public interface ibuildhousework
{
Void buildbalcony ();
Void buildkitchen ();
Void buildbedroom ();
Void buildparlor ();
Domainmodel. Entities. House deliverhouse ();
}
/// <Summary>
/// Chinese construction workers only build Chinese houses
/// </Summary>
Public class chineseworker: ibuildhousework
{
Entities. House myhouse = new entities. House ();
Public void buildbalcony ()
{
Myhouse. balcony = "I have built a Chinese balcony ";
Console. writeline ("I have built a Chinese balcony ");
}
Public void buildkitchen ()
{
Myhouse. balcony = "I have built a Chinese Kitchen ";
Console. writeline ("I created a Chinese Kitchen ");
}
Public void buildbedroom ()
{
Myhouse. balcony = "I have built a Chinese bedroom ";
Console. writeline ("I have built a Chinese bedroom ");
}
Public void buildparlor ()
{
Myhouse. balcony = "I have built a Chinese living room ";
Console. writeline ("I created a Chinese living room ");
}
Public entities. House deliverhouse ()
{
Console. writeline ("made a Chinese-style house! ");
Return myhouse;
}
}
/// <Summary>
/// Western workers will build western houses
/// </Summary>
Public class worker: ibuildhousework
{
Entities. House myhouse = new entities. House ();
Public void buildbalcony ()
{
Myhouse. balcony = "I have built a western balcony ";
Console. writeline ("I have created a Western-style balcony ");
}
Public void buildkitchen ()
{
Myhouse. balcony = "I created a western Kitchen ";
Console. writeline ("I created a western Kitchen ");
}
Public void buildbedroom ()
{
Myhouse. balcony = "I have created a western bedroom ";
Console. writeline ("I have created a Western-style bedroom ");
}
Public void buildparlor ()
{
Myhouse. balcony = "I created a Western-style living room ";
Console. writeline ("I created a Western-style living room ");
}
Public entities. House deliverhouse ()
{
Console. writeline ("made a Western-style house! ");
Return myhouse;
}
}
/// <Summary>
/// Architect
/// </Summary>
Public class effecect
{
Ibuildhousework;
Public effecect (ibuildhousework)
{
This. Work = work;
}
Public void directwork ()
{
Work. buildbalcony ();
Work. buildbedroom ();
Work. buildkitchen ();
}
}
Client call
Static void main (string [] ARGs)
{
Ibuildhousework buildhouse = new chineseworker ();
Effecect chinesearchitect = new effecect (buildhouse );
Chinesearchitect. directwork ();
Buildhouse. deliverhouse ();
Buildhouse = new worker ();
Effecect westgateect = new effecect (buildhouse );
Westgateect. directwork ();
Buildhouse. deliverhouse ();
Console. Read ();
}