GetResult() public method

public GetResult ( ) : Product
return Product
示例#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);
        }
示例#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
             */
        }
        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();
        }
示例#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 = b1.GetResult();
            p2.Show();

            Console.ReadKey();
        }
        static void Main()
        {
            Builder b1 = new ConcreteBuilder1();
            Director director = new Director();

            director.Construct(b1);
            var p1 = b1.GetResult();
            p1.Show();
        }
示例#7
0
        static void Main()
        {
            Builder b1 = new ConcreteBuilder1();

            Director.Construct(b1);
            var p1 = b1.GetResult();

            p1.Show();
        }
示例#8
0
        static void Main(string[] args)
        {
            Director director = new Director();
            Builder  b1       = new ConcreteBuilder1();

            director.Construct(b1);
            Product pr = b1.GetResult();

            pr.show();
            Console.ReadKey();
        }
示例#9
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();
        }
示例#10
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();
        }
        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();
        }
示例#12
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();
    }
示例#13
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();
        }
示例#14
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();
        }