/// <summary>

        /// Entry point into console application.

        /// </summary>

        public static void Main()
        {
            ConstrutorDoVeiculo construtor;

            // Create shop with vehicle builders

            Venda venda = new Venda();

            // Construct and display vehicles

            construtor = new ScooterBuilder();
            venda.Construtor(construtor);
            construtor.trazerVeiculo().Exibir();

            construtor = new CarBuilder();
            venda.Construtor(construtor);
            construtor.trazerVeiculo().Exibir();

            construtor = new MotoConstrutor();
            venda.Construtor(construtor);
            construtor.trazerVeiculo().Exibir();

            // Wait for user

            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            // Builder pattern without Director(Shop.cs)

            VehicleBuilder builder;

            builder = new ScooterBuilder();
            builder.MyConstruct();
            Vehicle firstVehicle = builder.Vehicle;

            firstVehicle.Show();

            builder = new CarBuilder();
            builder.MyConstruct();
            Vehicle secondVehicle = builder.Vehicle;

            secondVehicle.Show();

            builder = new MotorCycleBuilder();
            builder.MyConstruct();
            Vehicle thirdVehicle = builder.Vehicle;

            thirdVehicle.Show();

            Console.ReadKey();
        }
示例#3
0
        static void Main(string[] args)
        {
            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();

            // Wait for user

            Console.ReadKey();
        }
        public static void Main()
        {
            var constructor = new VehicleConstructor();

            var carBuilder = new CarBuilder();
            constructor.Constructor(carBuilder);
            carBuilder.Vehicle.Show();

            var scooterBuilder = new ScooterBuilder();
            constructor.Constructor(scooterBuilder);
            scooterBuilder.Vehicle.Show();
        }
示例#5
0
        static void Main(string[] args)
        {
            VehicleBuilder builder;

            Shop shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            Console.ReadKey();
        }
示例#6
0
        public static void Main()
        {
            VehicleBuilder builder;
            Factory        factory = new Factory();

            // Construct and display vehicles
            builder = new ScooterBuilder();
            factory.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            factory.Construct(builder);
            builder.Vehicle.Show();

            Console.ReadKey();
        }
示例#7
0
        internal static void Main()
        {
            VehicleBuilder builder;
            var            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();
        }
示例#8
0
        internal static void Main()
        {
            VehicleBuilder builder;
            var 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();
        }
示例#9
0
 /// <summary>
 /// Entry point into console application.
 /// </summary>
 public static void Main()
 {
     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();
     // Wait for user
     Console.ReadKey();
 }
示例#10
0
        private static void Main()
        {
            VehicleBuilder builder;
            var            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();
            Console.ReadKey();
        }
示例#11
0
        public static void Main()
        {
            // We can choose concrete constructor (director)
            IVehicleConstructor constructor = new VehicleConstructor();

            // And we can choose concrete builder
            VehicleBuilder builder = new ScooterBuilder();

            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();
        }
示例#12
0
        static void Main(string[] args)
        {
            var director = new Director();

            IVehicleBuilder motorCycle = new MotorCycleBuilder();

            director.Construct(motorCycle);
            motorCycle.GetResult.Show();

            IVehicleBuilder car = new CarBuilder();

            director.Construct(car);
            car.GetResult.Show();

            IVehicleBuilder scoote = new ScooterBuilder();

            director.Construct(scoote);
            scoote.GetResult.Show();
        }
示例#13
0
        public static void Run()
        {
            Console.WriteLine("This real-world code demonstates the Builder pattern in which different vehicles are assembled in a step-by-step fashion. The Shop uses VehicleBuilders to construct a variety of Vehicles in a series of sequential steps.");
            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();

            /*
             * ---------------------------
             * Vehicle Type: Scooter
             * Frame  : Scooter Frame
             * Engine : none
             #Wheels: 2
             #Doors : 0
             *
             * ---------------------------
             * Vehicle Type: Car
             * Frame  : Car Frame
             * Engine : 2500 cc
             #Wheels: 4
             #Doors : 4
             *
             * ---------------------------
             * Vehicle Type: MotorCycle
             * Frame  : MotorCycle Frame
             * Engine : 500 cc
             #Wheels: 2
             #Doors : 0
             */
        }
示例#14
0
        static void Main(string[] args)
        {
            TransportBuilder transportBuilder;                          // Create Builder,相当于中间件

            RealConstructor realConstructer = new RealConstructor();    // 实际的执行者,又称Director

            transportBuilder = new ScooterBuilder();                    // 建造滑板车
            realConstructer.Construct(transportBuilder);
            transportBuilder.Transport.ShowResult();

            transportBuilder = new MotorCycleBuilder();                 // 建造摩托车
            realConstructer.Construct(transportBuilder);
            transportBuilder.Transport.ShowResult();

            transportBuilder = new CarBuilder();                        // 建造汽车
            realConstructer.Construct(transportBuilder);
            transportBuilder.Transport.ShowResult();

            Console.ReadLine();
        }
示例#15
0
        static void Main(string[] args)
        {
            VehicleBuilder builder;

            Shop shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            Console.ReadKey();
        }
示例#16
0
        public static void Main()
        {
            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();
        }
示例#17
0
        static void Main(string[] args)
        {
            // different builders
            MotorCycleBuilder motorCycleBuilder = new MotorCycleBuilder();
            CarBuilder        carBuilder        = new CarBuilder();
            ScooterBuilder    scooterBuilder    = new ScooterBuilder();

            // create a director object
            Shop shop = new Shop();

            shop.Construct(motorCycleBuilder);
            motorCycleBuilder.Vehicle.Show();

            shop.Construct(carBuilder);
            carBuilder.Vehicle.Show();

            shop.Construct(scooterBuilder);
            scooterBuilder.Vehicle.Show();

            Console.ReadKey();
        }
示例#18
0
        static void Main(string[] args)
        {
            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();

            Showable adapter = new TransportAdapter(builder.Vehicle);
            //adapter.Show();
        }
示例#19
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();
        }
        public static void Main()
        {
            AVehicleBuilder builder;

            Shop shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            Console.WriteLine("---------------------------");
            Console.WriteLine(builder.Vehicle);

            builder = new CarBuilder();
            shop.Construct(builder);
            Console.WriteLine("\r\n---------------------------");
            Console.WriteLine(builder.Vehicle);

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            Console.WriteLine("\r\n---------------------------");
            Console.WriteLine(builder.Vehicle);

            Console.ReadKey();
        }