public static void Display() { Builder builder = new ConcreteBuilder(); Director director = new Director(builder); director.Construct(); Product product = builder.GetResult(); }
private void RunBuilderTest() { Builder a_builder = new ConcreteBuilder(); Director a_derector = new Director(a_builder); a_derector.Construct(); BuilderPattern.Product a_product = a_builder.GetResult(); }
/// <summary> /// 建造者模式的基本类 /// </summary> void Build_Base_main() { Director director = new Director(); //声明一个指挥者 Builder B1 = new ConcreteBuilder(); //声明 一个建造者 director.Construct(B1); //根据用户的需要建造商品 Product p1 = B1.GetResult(); // 得到结果 进行商品的建造 p1.Show(); // 进行 显示商品 }
static void Main(string[] args) { //house building Builder.Builder b = new ConcreteBuilder(); Foreman f = new Foreman(b); f.Construct(); House h = b.GetResult(); //bottle building BottleBuilder.BottleBuilder bb = new PepsiBottleBuilder(); Director d = new Director(bb); d.Construct(); Bottle bottle = bb.GetBottle(); }
static void Main(string[] args) { var builder = new ConcreteBuilder(); var director = new Director(builder); director.BuildProductWithTwoArms(); var product = builder.GetResult(); foreach (var part in product.Parts) { Console.WriteLine(part); } }
public void StructuralTest() { Director director = new Director(); Builder build1 = new ConcreteBuilder(); Builder build2 = new ConcreteBuilder2(); director.Construct(build1); director.Construct(build2); Product product1 = build1.GetResult(); Product product2 = build2.GetResult(); product1.Show(); product2.Show(); }
static void Main(string[] args) { IBuilder builder = new ConcreteBuilder(); Director director = new Director(builder); director.Construct(); Product product = builder.GetResult(); product.Show(); /* * IBuilder b = new ConcreteBuilder(); * b.BuildPartA(); * b.BuildPartB(); * Product p = b.GetResult(); * p.Show(); */ }