Exemplo n.º 1
0
 public Car(string model, Engine engine, Cargo cargo, Tire tires)
 {
     this.Model = model;
     this.Engine = engine;
     this.Cargo = cargo;
     this.Tire = tires;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int numberOfCars = int.Parse(Console.ReadLine());
            List<Car> cars = new List<Car>();

            for (int i = 0; i < numberOfCars; i++)
            {
                string[] input = Console.ReadLine().Split();
                string model = input[0];

                var engine = new Engine(int.Parse(input[1]), int.Parse(input[2]));

                var cargo = new Cargo(int.Parse(input[3]), (CargoType)Enum.Parse(typeof(CargoType), input[4]));

                var tire =
                    new Tire(
                        new List<double>
                            {
                                double.Parse(input[5]),
                                double.Parse(input[7]),
                                double.Parse(input[9]),
                                double.Parse(input[11])
                            },
                        new List<int>
                            {
                                int.Parse(input[6]),
                                int.Parse(input[8]),
                                int.Parse(input[10]),
                                int.Parse(input[12])
                            });
             


                var car = new Car(model, engine, cargo, tire);
                cars.Add(car);
            }

            string command = Console.ReadLine();

            if (command == "fragile")
            {
                var newCars =
                    cars.Where(x => x.Cargo.CargoType == CargoType.fragile)
                        .Where(y => y.Tire.TireOnePreassure.Exists(t => t < 1d))
                        .ToList();
            }
        }