GetResult() public method

public GetResult ( ) : Product
return Product
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Builder  builder  = new ConcreteBuilder1();
            Director director = new Director();

            director.Construct(builder);
            Console.WriteLine(builder.GetResult().PartA);
            Console.WriteLine(builder.GetResult().PartB);

            builder = new ConcreteBuilder2();
            director.Construct(builder);
            Console.WriteLine(builder.GetResult().PartA);
            Console.WriteLine(builder.GetResult().PartB);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>

        public static void Main()
        {
            // 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();
        }
        public static void Run()
        {
            Console.WriteLine("This structural code demonstrates the Builder pattern in which complex objects are created in a step-by-step fashion. The construction process can create different object representations and provides a high level of control over the assembly of the objects.");
            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();

            /*
             * Product Parts -------
             * PartA
             * PartB
             *
             * Product Parts -------
             * PartX
             * PartY
             */
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Director director = new Director();



            Builder b1 = new ConcreteBuilder1();

            Builder b2 = new ConcreteBuilder2();



            // Constructor dos productos

            director.Construct(b1);

            Product p1 = b1.GetResult();

            p1.Show();



            director.Construct(b2);

            Product p2 = b2.GetResult();

            p2.Show();



            // Esperando a usar

            Console.ReadKey();
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        public static void Main()
        {
            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.ReadKey();
        }
Exemplo n.º 7
0
        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.ReadKey();
        }
        static void Main(string[] args)
        {
            Director director = new Director();

            IBuilder builder1 = new ConcreteBuilder1();
            IBuilder builder2 = new ConcreteBuilder2();

            director.Construct(builder1);
            Product product1 = builder1.GetResult();
            product1.Show();

            director.Construct(builder2);
            Product product2 = builder2.GetResult();
            product2.Show();

            Console.Read();
        }
Exemplo n.º 9
0
    public static void Main()
    {
      // 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.Read();
    }
Exemplo n.º 10
0
        public static void Main(string[] args)
        {
            var director = new Director();

            Builder b1 = new ConcreteBuilder1();
            Builder b2 = new ConcreteBuilder2();

            director.Construct(b1);
            var product1 = b1.GetResult();

            product1.Show();

            Console.WriteLine();

            director.Construct(b2);
            var product2 = b2.GetResult();

            product2.Show();

            Console.ReadKey();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            #region 结构实现
            // Create director and builders
            Director director = new Director();

            Structural.Builder b1 = new ConcreteBuilder1();
            Structural.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();
            #endregion

            Console.WriteLine("******************************");

            #region 实践应用
            VehicleBuilder builder;
            Shop           shop = new Shop();

            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();
            #endregion

            Console.ReadKey();
        }