예제 #1
0
        static void Main(string[] args)
        {
            AbstractCar     car      = new Saloon(new TurboEngine(1500), VehicleColour.Blue);
            VehicleBuilder  builder  = new CarBuilder(car);
            VehicleDirector director = new CarDirector();
            IVehicle        v        = director.Build(builder);

            Console.WriteLine(v);
            Console.Read();
        }
예제 #2
0
        static void Main(string[] args)
        {
            //向左制造引擎,颜色
            AbstractCar    car     = new Saloon(new StandardEngine(1300));
            VehicleBuilder Builder = new CarBuilder(car);
            //向右制造汽车框架结构
            VehicleDirector director = new CarDirector();

            Console.WriteLine(director.Build(Builder));
            Console.Read();
        }
예제 #3
0
        static void Main()
        {
            CarBuilder basicCarBuilder = new BasicCarBuilder();
            CarBuilder superCarBuilder = new SuperCarBuilder();

            List <CarBuilder> builders = new List <CarBuilder>()
            {
                basicCarBuilder,
                superCarBuilder
            };

            CarDirector director = new CarDirector();

            foreach (CarBuilder builder in builders)
            {
                Car car = director.Build(builder);
                Console.WriteLine($"Car Built By: {builder.GetType().Name}");
                Console.WriteLine($"Top Speed: {car.TopSpeed}");
                Console.WriteLine($"Horse Power: {car.HorsePower}");
                Console.WriteLine();
            }

            Console.Read();
        }