public Car(string model, Engine engine, Cargo cargo, TireCollection tires) { this.Model = model; this.Engine = engine; this.Cargo = cargo; this.Tires = tires; }
static void Main(string[] args) { List <Car> cars = new List <Car>(); 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]); int cargoWeight = int.Parse(parameters[3]); string cargoType = parameters[4]; double tire1Pressure = double.Parse(parameters[5]); int tire1age = int.Parse(parameters[6]); double tire2Pressure = double.Parse(parameters[7]); int tire2age = int.Parse(parameters[8]); double tire3Pressure = double.Parse(parameters[9]); int tire3age = int.Parse(parameters[10]); double tire4Pressure = double.Parse(parameters[11]); int tire4age = int.Parse(parameters[12]); var currEngine = new Engine(engineSpeed, enginePower); var currCargo = new Cargo(cargoWeight, cargoType); var currTires = new TireCollection(tire1Pressure, tire1age, tire2Pressure, tire2age, tire3Pressure, tire3age, tire4Pressure, tire4age); cars.Add(new Car(model, currEngine, currCargo, currTires)); } string command = Console.ReadLine(); if (command == "fragile") { List <string> fragile = cars .Where(x => x.Cargo.CargoType == "fragile" && x.Tires.Tires.Any(y => y.Key < 1)) .Select(x => x.Model) .ToList(); Console.WriteLine(string.Join(Environment.NewLine, fragile)); } else { List <string> flamable = cars .Where(x => x.Cargo.CargoType == "flamable" && x.Engine.EnginePower > 250) .Select(x => x.Model) .ToList(); Console.WriteLine(string.Join(Environment.NewLine, flamable)); } }