예제 #1
0
        public void CreateCar(CarFactory carFactory)
        {
            Wheels = new List <IWheel>();
            for (int i = 1; i <= 4; i++)
            {
                Wheels.Add(carFactory.CreateWheel());
            }

            Windshield = carFactory.CreateWindshield();
            Engine     = carFactory.CreateEngine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            logSection("DESIGN PATTERNS: ABSTRACT FACTORY\n");

            logSection("1. Instantiating object c1: popular car...");
            c1 = CarFactory.MakeCar(CarSophisticationLevel.Popular);
            logObjectState(nameof(c1), c1);

            log.AppendLine();

            logSection("2. Instantiating object c2: luxury car...");
            c2 = CarFactory.MakeCar(CarSophisticationLevel.Luxury);
            logObjectState(nameof(c2), c2);

            logFlush();

            waitForKeyPress();
        }
예제 #3
0
 public Driver(CarFactory carFactory)
 {
     CarFactory = carFactory;
     SportsCar = CarFactory.CreateSportsCar();
     FamilyCar = CarFactory.CreateFamilyCar();
 }
예제 #4
0
 public Driver(CarFactory carFactory)
 {
     CarFactory = carFactory;
     SportsCar  = CarFactory.CreateSportsCar();
     FamilyCar  = CarFactory.CreateFamilyCar();
 }