Exemplo n.º 1
0
        public static IVehicle Make(Category category, DrivingStyle style, VehicleColour colour)
        {
            VehicleFactory factory;

            if (category == Category.Car)
            {
                factory = new CarFactory();
            }
            else
            {
                factory = new VanFactory();
            }

            return(factory.Build(style, colour));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            logSection("DESIGN PATTERNS: FACTORY METHOD\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();
        }