示例#1
0
    public static void Main()
    {
        var threeWheelRedCar  = CarMaker.BuildCar(new ThreeWheelsRedCar());
        var fourWheelBlackCar = CarMaker.BuildCar(new FourWheelsBlackCar());

        threeWheelRedCar.display();
        fourWheelBlackCar.display();
    }
示例#2
0
        private static void BuildAudiCar()
        {
            Console.WriteLine("-> Start Audi car builder <-");

            var carMaker2 = new CarMaker(new AudiCarBuilder());

            carMaker2.BuildCar();
            var car2 = carMaker2.GetCar();

            car2.Display();

            Console.WriteLine("-> End Audi car builder <-");
            Console.WriteLine();
        }
示例#3
0
        private static void BuildVolkswagenCar()
        {
            Console.WriteLine("-> Start Volkswagen car builder <-");

            var carMaker3 = new CarMaker(new VolkswagenCarBuilder());

            carMaker3.BuildCar();
            var car3 = carMaker3.GetCar();

            car3.Display();

            Console.WriteLine("-> Start Volkswagen car builder <-");
            Console.WriteLine();
        }
示例#4
0
        private static void BuildBmwCar()
        {
            Console.WriteLine("-> Start BMW car builder <-");

            var carMaker = new CarMaker(new BmwCarBuilder());

            carMaker.BuildCar();
            var car1 = carMaker.GetCar();

            car1.Display();

            Console.WriteLine("-> End BMW car builder <-");
            Console.WriteLine();
        }
示例#5
0
        private static void callBuilderPattern()
        {
            CarMaker carMaker = new CarMaker(new FordBuilder());

            carMaker.BuildCar();
            var car1 = carMaker.GetCar();

            car1.PrintCar();

            CarMaker carMaker2 = new CarMaker(new HundaiBuilder());

            carMaker2.BuildCar();
            var car2 = carMaker2.GetCar();

            car2.PrintCar();
        }