Ejemplo n.º 1
0
        public static void Main()
        {
            CarFactory    carFactory    = new CarFactory();
            CarCatalog    cars          = new CarCatalog();
            EngineFactory engineFactory = new EngineFactory();
            EngineCatalog engines       = new EngineCatalog();
            int           engineCount   = int.Parse(Console.ReadLine());

            for (int i = 0; i < engineCount; i++)
            {
                string[] parameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                engines.Add(engineFactory.Create(parameters));
            }

            int carCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < carCount; i++)
            {
                string[] parameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                cars.Add(carFactory.Create(engines, parameters));
            }

            foreach (var car in cars)
            {
                Console.WriteLine(car);
            }
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            var carCatalogue    = new CarCatalogue();
            var engineCatalogue = new EngineCatalogue();

            int engineCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < engineCount; i++)
            {
                string[] parameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                var engineFactory = new EngineFactory(parameters);
                var newEngine     = engineFactory.Create();

                engineCatalogue.Add(newEngine);
            }

            int carCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < carCount; i++)
            {
                string[] parameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                var carFactory = new CarFactory(parameters, engineCatalogue);
                var newCar     = carFactory.Create();

                carCatalogue.Add(newCar);
            }

            foreach (var car in carCatalogue.GetAllCars())
            {
                Console.WriteLine(car);
            }
        }
Ejemplo n.º 3
0
        public void AddCar(string[] parameters)
        {
            Car car = carFactory.Create(parameters, this.engines);

            cars.Add(car);
        }