Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Factory factory = new AirplanFactory();
            var     airplan = factory.Create();

            factory = new CarFactory();
            var car = factory.Create();

            factory = new ScooterFactory();
            var scooter = factory.Create();

            Console.WriteLine(airplan.Model);
            Console.WriteLine(car.Model);
            Console.WriteLine(scooter.Model);
        }
Exemplo n.º 2
0
        static void ExecuteProblem2Solution()
        {
            ICarSupplier cs1 = CarFactory.GetCarInstance(0);
            ICarSupplier cs2 = CarFactory.GetCarInstance(1);
            ICarSupplier cs3 = CarFactory.GetCarInstance(2);
            ICarSupplier cs4 = CarFactory.GetCarInstance(3);

            List <ICarSupplier> carSuppliers = new List <ICarSupplier> {
                cs1, cs2, cs3, cs4
            };

            carSuppliers.ForEach(x => {
                x.GetCarModel();
                Console.WriteLine("And Coloar is " + x.CarColor);
                Console.WriteLine();
            });
        }