Beispiel #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();
        }
Beispiel #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();
        }
 public Driver(CarFactory carFactory)
 {
     CarFactory = carFactory;
     SportsCar = CarFactory.CreateSportsCar();
     FamilyCar = CarFactory.CreateFamilyCar();
 }
 public Driver(CarFactory carFactory)
 {
     CarFactory = carFactory;
     SportsCar  = CarFactory.CreateSportsCar();
     FamilyCar  = CarFactory.CreateFamilyCar();
 }