Example #1
0
        public void Add(string[] parameters)
        {
            CarFactory carfactory = new CarFactory();
            Car        car        = carfactory.Create(parameters);

            cars.Add(car);
        }
Example #2
0
        public static void Run()
        {
            int lines = int.Parse(Console.ReadLine());

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

                string model = parameters[0];

                int engineSpeed = int.Parse(parameters[1]);
                int enginePower = int.Parse(parameters[2]);

                var engine = CarFactory.AddEngine(engineSpeed, enginePower);


                int    cargoWeight = int.Parse(parameters[3]);
                string cargoType   = parameters[4];

                var cargo = CarFactory.AddCargo(cargoWeight, cargoType);

                var tiresInfo = parameters.Skip(5).ToArray();

                var tires = CarFactory.AddTires(tiresInfo);

                CarFactory.AddNewCarInGarage(model, engine, cargo, tires);
            }
        }
 public CarCatalog(EngineFactory engineFactory, CargoFactory cargoFactory, CarFactory carFactory)
 {
     this.cars          = new List <Car>();
     this.engineFactory = engineFactory;
     this.cargoFactory  = cargoFactory;
     this.carFactory    = carFactory;
 }
Example #4
0
        private static void CreatingCars(CarFactory cars)
        {
            string[] parameters = Console.ReadLine()
                                  .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            cars.Add(parameters);
        }
Example #5
0
 public CarCatalog()
 {
     this.cars          = new List <Car>();
     this.carFactory    = new CarFactory();
     this.engineFactory = new EngineFactory();
     this.cargoFactory  = new CargoFactory();
     this.tiresFactory  = new TiresFactory();
 }
Example #6
0
        static void Main(string[] args)
        {
            CarFactory cars  = new CarFactory();
            int        lines = int.Parse(Console.ReadLine());

            for (int i = 0; i < lines; i++)
            {
                CreatingCars(cars);
            }

            Printing(cars);
        }
Example #7
0
        public void Run()
        {
            CarFactory    carFactory    = new CarFactory();
            EngineFactory engineFactory = new EngineFactory();
            CargoFactory  cargoFactory  = new CargoFactory();
            TireFactory   tireFactory   = new TireFactory();

            CarCatalog carCatalog = new CarCatalog(carFactory, engineFactory, cargoFactory, tireFactory);

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

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

                carCatalog.Add(parameters);
            }

            string command = Console.ReadLine();

            switch (command)
            {
            case "fragile":
                List <string> fragile = carCatalog.GetCars()
                                        .Where(x => x.Cargo.Type == "fragile" && x.Tires.Any(y => y.Pressure < 1))
                                        .Select(x => x.Model)
                                        .ToList();

                PrintInfo(fragile);
                break;

            case "flamable":
                List <string> flamable = carCatalog.GetCars()
                                         .Where(x => x.Cargo.Type == "flamable" && x.Engine.Power > 250)
                                         .Select(x => x.Model)
                                         .ToList();

                PrintInfo(flamable);
                break;
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            EngineFactory engineFactory = new EngineFactory();
            CargoFactory  cargoFactory  = new CargoFactory();
            CarFactory    carFactory    = new CarFactory();
            CarCatalogue  carCatalogue  = new CarCatalogue(
                engineFactory,
                cargoFactory,
                carFactory);

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

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

                carCatalogue.Add(parameters);
            }

            string command = Console.ReadLine();

            if (command == "fragile")
            {
                List <string> fragile = carCatalogue.GetCars()
                                        .Where(x => x.Cargo.Type == "fragile" && x.Tires.Any(y => y.Pressure < 1))
                                        .Select(x => x.Model)
                                        .ToList();

                Console.WriteLine(string.Join(Environment.NewLine, fragile));
            }
            else
            {
                List <string> flamable = carCatalogue.GetCars()
                                         .Where(x => x.Cargo.Type == "flamable" && x.Engine.Power > 250)
                                         .Select(x => x.Model)
                                         .ToList();

                Console.WriteLine(string.Join(Environment.NewLine, flamable));
            }
        }
Example #9
0
        private static void Printing(CarFactory cars)
        {
            string command = Console.ReadLine();

            if (command == "fragile")
            {
                List <string> fragile = cars.carCataloque
                                        .Where(x => x.newCargo.cargoType == "fragile" && x.Tires.Any(y => y.Pressure < 1))
                                        .Select(x => x.model)
                                        .ToList();

                Console.WriteLine(string.Join(Environment.NewLine, fragile));
            }
            else
            {
                List <string> flamable = cars.carCataloque
                                         .Where(x => x.newCargo.cargoType == "flamable" && x.Engine.enginePower > 250)
                                         .Select(x => x.model)
                                         .ToList();

                Console.WriteLine(string.Join(Environment.NewLine, flamable));
            }
        }