Builder mode. A series of methods are provided to process the product. You can select any combination of methods, but you must write the builder mode. Code Strong business knowledge is required. Finally, you can get the corresponding product.
UML diagram:
The UML diagram shows that the builder contains the product construction and acquisition. The ctor wizard determines how to build the product.
For Model Construction In Dota, You need to implement the following interface ibuilder, including creating models, adding names, setting skills, and textures. If you are not interested in the list, you can complete it yourself.
Internal Interface Ibuilder
{
Void Createmodel ();
Void Addname ();
Void Setskill ();
Void Maps ();
}
The main character is our builder. The model object is instantiated in the constructor, which contains all the construction processes in ibuilder. For the model class, see the complete code.
Public Class Modelbuilder: ibuilder
{
Private Model _ model;
PublicModelbuilder ()
{
_ Model= NewModel ();
}
PublicModel GetModel ()
{
Return_ Model;
}
# RegionIbuilder Member
Public void createmodel ()
{< br> _ model. addproperty ( " createmodel " , " createmodel " );
}
Public void addname ()
{< br> _ model. addproperty ( " addname " , " addname " );
}
Public void setskill ()
{< br> _ model. addproperty ( " setskill " , " setskill " );
}
Public VoidMaps ()
{
_ Model. addproperty ("Maps","Maps");
}
# Endregion
}
Test code:
Dotapatternlibrary. Builder. modelbuilder mbobj = new dotapatternlibrary. Builder. modelbuilder ();
Mbobj. createmodel ();
Mbobj. addname ();
Mbobjnew. Maps ();
Dotapatternlibrary. Builder. Model = mbobj. GetModel ();
Model. Show ();
Dotapatternlibrary. Builder. modelbuilder mbobjnew = new dotapatternlibrary. Builder. modelbuilder ();
Mbobjnew. createmodel ();
Mbobjnew. addname ();
Mbobjnew. setskill ();
Mbobjnew. Maps ();
Model = mbobjnew. GetModel ();
Model. Show ();
One in the test code is a number, the other is a hero, and the two build processes are inferior to the setkill method, because the tree does not require skills.
Complete code: Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. text;
Using System. collections;
UsingDotacommon;
namespace dotapatternlibrary. builder
{< br> internal interface ibuilder
{< br> void createmodel ();
void addname ();
void setskill ();
void maps ();
}
Public ClassModelbuilder: ibuilder
{
PrivateModel _ model;
PublicModelbuilder ()
{
_ Model= NewModel ();
}
PublicModel GetModel ()
{
Return_ Model;
}
# RegionIbuilder Member
Public void createmodel ()
{< br> _ model. addproperty ( " createmodel " , " createmodel " );
}
Public void addname ()
{< br> _ model. addproperty ( " addname " , " addname " );
}
Public void setskill ()
{< br> _ model. addproperty ( " setskill " , " setskill " );
}
Public VoidMaps ()
{
_ Model. addproperty ("Maps","Maps");
}
# Endregion
}
Public Class Model
{
Hashtable htobj = New Hashtable ();
Internal Void Addproperty ( String Key, String Value)
{
Htobj. Add (Key, value );
}
Public Void Show ()
{
Foreach ( String Value In Htobj. values)
{
Landpyform. Form. outputresult (value );
}
}
}
}