private static List <engine> Addengineinfo(int n, List <engine> Engine)
 {
     for (int i = 0; i < n; i++)
     {
         string[] splitedintput = Console.ReadLine().Split(' ');
         string   enginemodel   = splitedintput[0];
         string   power         = splitedintput[1];
         var      displacement  = "n/a";
         string   efficiency    = "n/a";
         if (splitedintput.Length >= 3)
         {
             if (char.IsNumber(splitedintput[2], 0))
             {
                 displacement = splitedintput[2];
             }
             else
             {
                 displacement = "n/a";
                 efficiency   = splitedintput[2];
             }
         }
         if (splitedintput.Length == 4)
         {
             efficiency = splitedintput[3];
         }
         engine engine = new engine(enginemodel, power, displacement, efficiency);
         Engine.Add(engine);
     }
     return(Engine);
 }
Beispiel #2
0
 public Car(string model, engine engine, cargo cargo, tire tire)
 {
     Model  = model;
     Engine = engine;
     Cargo  = cargo;
     Tire   = tire;
 }
Beispiel #3
0
        public static void Main(string[] args)
        {
            int n    = int.Parse(Console.ReadLine());
            var cars = new List <Car>();

            for (int i = 0; i < n; i++)
            {
                string[] splitedinput = Console.ReadLine().Split(" ");
                tire     tire         = new tire(double.Parse(splitedinput[5]), int.Parse(splitedinput[6]), double.Parse(splitedinput[7]),
                                                 int.Parse(splitedinput[8]), double.Parse(splitedinput[9]), int.Parse(splitedinput[10]), double.Parse(splitedinput[11]),
                                                 int.Parse(splitedinput[12]));
                cargo  cargo  = new cargo(int.Parse(splitedinput[3]), splitedinput[4]);
                engine engine = new engine(int.Parse(splitedinput[1]), int.Parse(splitedinput[2]));
                Car    car    = new Car(splitedinput[0], engine, cargo, tire);
                cars.Add(car);
            }
            string lastinput = Console.ReadLine();

            if (lastinput == "fragile")
            {
                cars = cars.Where(x => x.Cargo.CargoType == lastinput).ToList();
                foreach (var car in cars)
                {
                    double first  = car.Tire.FirstTirePressure;
                    double second = car.Tire.SecondTirePressure;
                    double third  = car.Tire.ThirdTirePressure;
                    double fourth = car.Tire.FourthTirePressure;
                    if (first < 1 || second < 1 || third < 1 || fourth < 1)
                    {
                        Console.WriteLine(car.Model);
                    }
                }
            }
            else if (lastinput == "flamable")
            {
                cars = cars.Where(x => x.Cargo.CargoType == lastinput).ToList();
                foreach (var car in cars)
                {
                    if (car.Engine.EnginePower > 250)
                    {
                        Console.WriteLine(car.Model);
                    }
                }
            }
        }