The builder mode separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.
Mode Structure
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Signature + CjxwPiA8L3A + signature/Signature/bPMt9a47r + signature/Signature + rPJvt/Signature + x7c/ztcSy + signature + zb/Signature/zDx6Ostvi + signature + signature/Signature/PE2rK/Signature + signature + yr7A/TwvaDE + cjxwp?vcd4kpha + signature/z17C1vbH5z + signature/qqOstdq2/ rk9sn21388/zt8W9 + Milo6y12sj9sr2w0bH5z + TDxbnYyc + hozwvcD4KPHA + PGJyPgo8L3A + CjxwPiAgIAo8aW1nIHNyYz0 =" http://www.2cto.com/uploadfile/Collfiles/20140321/20140321125711267.jpg "Alt =" \ ">
Similarly, we can install other things in the refrigerator following this step: for example, expired milk, leftover Pizza, or even imitating Russian baby sets, install a refrigerator (for details about how to use the refrigerator, refer to the refrigerator user manual. I bet refrigerator is definitely not used like this ..).. Let's take a look at the code for installing an elephant:
Namespace abstracts the elephant refrigerator installation {/* into a class in the construction process, and stores "things in the refrigerator. That is to say, no matter what is loaded into the refrigerator * you have to follow this step, and you cannot lose it in one step. */Abstract class put0000fridge {public abstract void OpenFridge (); public abstract void PutInto (); public abstract void CloseFridge ();}/* write a class to hold an elephant in the refrigerator, then let this class inherit from put?fridge *. In this class, it shows how to install an elephant in a refrigerator. */Class PutElephantIntoFri: put?fridge {private string name; public PutElephantIntoFri (string name) {this. name = name;} public override void OpenFridge () {Console. writeLine ("opens the refrigerator door ~~ ");} Public override void PutInto () {Console. WriteLine (" load {0} into the refrigerator. ", Name);} public override void CloseFridge () {Console. WriteLine (" closed the refrigerator door. ") ;}}/* CONDUCTOR: used to direct the East suit refrigerator process and use it to isolate the association between users and the * construction process. */Class Director {private put0000fridge pif; // specify what to implement when constructing the public Director (put0000fridge pif) {this. pif = pif;}/* write a process of installing an elephant in the refrigerator to hide the specific process of installing an elephant in the refrigerator *. You only need to call this method. */Public void createput1_fif () {pif. openFridge (); pif. putInto (); pif. closeFridge () ;}} class Program {static void Main (string [] args) {PutElephantIntoFri peif = new PutElephantIntoFri ("elephant"); Director ctor = new director (peif ); director. createPutIntoFif (); Console. writeLine ("");}}}
Finally, run the command and install the refrigerator...