public static void Main() { var carCatalogue = new CarCatalogue(); int lines = int.Parse(Console.ReadLine()); for (int i = 0; i < lines; i++) { string[] carParameters = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var carCreator = new CarCreator(carParameters); var newCar = carCreator.Create(); carCatalogue.Add(newCar); } string command = Console.ReadLine(); if (command == "fragile") { var fragileVehicles = carCatalogue.GetFragileVehicles(); PrintVehicles(fragileVehicles); } else { var flamableVehicles = carCatalogue.GetFlamableVehicles(); PrintVehicles(flamableVehicles); } }
static void Main(string[] args) { CarCatalogue carCatalogue = new CarCatalogue(); 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)); } }