public static void Main(string[] args) { var director = new Director(); Builder builder1 = new ConcreteBuilder1(), builder2 = new ConcreteBuilder2(); director.Construct(builder1); director.Construct(builder2); builder1.GetResult().Show(); builder2.GetResult().Show(); Console.ReadLine(); }
private static void Main(string[] args) { var director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); director.Construct(b1); var p1 = b1.GetResult(); p1.Show(); director.Construct(b2); var p2 = b2.GetResult(); p2.Show(); Console.ReadKey(); }
static void Main(string[] args) { Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); director.Construct(b1); var product1 = b1.GetResult(); product1.Show(); director.Construct(b2); var product2 = b2.GetResult(); product2.Show(); }
/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { // create director and builders Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // create product using builder 1 director.Construct(b1); Product p1 = b1.GetResult(); // create product using builder 1 director.Construct(b2); Product p2 = b2.GetResult(); }
static void Main(string[] args) { Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); director.Construct(b1); Product p1 = b1.GetResult(); p1.Show(); director.Construct(b2); Product p2 = b2.GetResult(); p2.Show(); Console.Read(); }
private static void Main(string[] args) { var director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); director.Construct(b1); var p1 = b1.GetResult(); p1.Show(); director.Construct(b2); var p2 = b2.GetResult(); p2.Show(); Console.ReadKey(); }
private static void StructuralBuilder() { // Create director and builders Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // Construct two products director.Construct(b1); Product p1 = b1.GetResult(); p1.Show(); director.Construct(b2); Product p2 = b2.GetResult(); p2.Show(); // Wait for user Console.ReadKey(); }
static void Main(string[] args) { // Create director and builders Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // Construct two products director.Construct(b1); Product p1 = b1.GetResult(); p1.Show(); director.Construct(b2); Product p2 = b2.GetResult(); p2.Show(); //1.练习 VehicleBuilder builder; // Create shop with vehicle builders Shop shop = new Shop(); // Construct and display vehicles builder = new ScooterBuilder(); shop.Construct(builder); builder.Vehicle.Show(); builder = new CarBuilder(); shop.Construct(builder); builder.Vehicle.Show(); builder = new MotorCycleBuilder(); shop.Construct(builder); builder.Vehicle.Show(); Console.ReadKey(); }
static void Main(string[] args) { Director director = new Director(); //声明一个精细构建1的类 ConcreteBuilder1 cb1 = new ConcreteBuilder1(); //通过统一的构造 director.Construct(cb1); //得到构造后的结果 Product p1 = cb1.GetResult(); //声明一个精细构建2的类 ConcreteBuilder2 cb2 = new ConcreteBuilder2(); //通过统一的构造 director.Construct(cb2); //得到构造后的结果 Product p2 = cb2.GetResult(); p1.Show(); p2.Show(); Console.ReadKey(); }