Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P01_RawData
- {
- public class StartUp
- {
- static void Main(string[] args)
- {
- List<Car> cars = new List<Car>();
- int lines = int.Parse(Console.ReadLine());
- for (int i = 0; i < lines; i++)
- {
- InputDataProccesing(cars);
- }
- string command = Console.ReadLine();
- if (command == "fragile")
- {
- Fragile(cars);
- }
- else
- {
- Flamble(cars);
- }
- }
- private static void InputDataProccesing(List<Car> cars)
- {
- 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 firstTirePressure = double.Parse(parameters[5]);
- int firstTireAge = int.Parse(parameters[6]);
- double secondTirePressure = double.Parse(parameters[7]);
- int secondTireAge = int.Parse(parameters[8]);
- double thirdTirePressure = double.Parse(parameters[9]);
- int thirdTireAge = int.Parse(parameters[10]);
- double fourthTirePressure = double.Parse(parameters[11]);
- int fourthTireAge = int.Parse(parameters[12]);
- cars.Add(new Car(model, engineSpeed, enginePower, cargoWeight, cargoType, firstTirePressure, firstTireAge, secondTirePressure, secondTireAge, thirdTirePressure, thirdTireAge, fourthTirePressure, fourthTireAge));
- }
- private static void Flamble(List<Car> cars)
- {
- List<string> flamable = cars
- .Where(x => x.cargoType == "flamable" && x.enginePower > 250)
- .Select(x => x.model)
- .ToList();
- Console.WriteLine(string.Join(Environment.NewLine, flamable));
- }
- private static void Fragile(List<Car> cars)
- {
- List<string> fragile = cars
- .Where(x => x.cargoType == "fragile" && x.tires.Any(y => y.Key < 1))
- .Select(x => x.model)
- .ToList();
- Console.WriteLine(string.Join(Environment.NewLine, fragile));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement