예제 #1
0
파일: Car.cs 프로젝트: hammer4/SoftUni
 public Car(string model, Engine engine, Cargo cargo, List<Tyre> tires)
 {
     this.model = model;
     this.engine = engine;
     this.cargo = cargo;
     this.tires = tires;
 }
예제 #2
0
        static void Main(string[] args)
        {
            Dictionary<string, Car> cars = new Dictionary<string, Car>();

            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split();

                var model = input[0];
                var engineSpeed = long.Parse(input[1]);
                var enginePower = long.Parse(input[2]);
                var cargoWeight = long.Parse(input[3]);
                var cargoType = input[4];
                var tier1P = double.Parse(input[5]);
                var tier1A = int.Parse(input[6]);
                var tier2P = double.Parse(input[7]);
                var tier2A = int.Parse(input[8]);
                var tier3P = double.Parse(input[9]);
                var tier3A = int.Parse(input[10]);
                var tier4P = double.Parse(input[11]);
                var tier4A = int.Parse(input[12]);

                var engine = new Engine(engineSpeed, enginePower);
                var cargo = new Cargo(cargoWeight, cargoType);

                var tierOne = new Tier(tier1P, tier1A);
                var tierTwo = new Tier(tier2P, tier2A);
                var tierThree = new Tier(tier3P, tier3A);
                var tierFour = new Tier(tier4P, tier4A);
                List<Tier> tiers = new List<Tier> { tierOne, tierTwo, tierThree, tierFour };
                var car = new Car(model, engine, cargo, tiers);
                cars[car.Model] = car;
            }

            var type = Console.ReadLine();
            if (type == "fragile")
            {
                var result = cars.Where(x => x.Value.Tiers.Exists(y => y.TirePressure < 1d));
                foreach (var car in result)
                {
                    Console.WriteLine(car.Key);
                }
            }
            else
            {
                var result = cars.Where(x => x.Value.Engine.EnginePower > 250);
                foreach (var car in result)
                {
                    Console.WriteLine(car.Key);
                }
            }
        }
예제 #3
0
 public Car(string model,
     string engineSpeed, string enginePower,
     string cargoWeight, string cargoType,
     string t1Pressure, string t1Age,
     string t2Pressure, string t2Age,
     string t3Pressure, string t3Age,
     string t4Pressure, string t4Age)
 {
     this.Model = model;
     this.Engine = new Engine(int.Parse(engineSpeed), int.Parse(enginePower));
     this.Cargo = new Cargo(int.Parse(cargoWeight), cargoType);
     // =========================
     this.TireOne = new Tire(double.Parse(t1Pressure), int.Parse(t1Age));
     this.TireTwo = new Tire(double.Parse(t2Pressure), int.Parse(t2Age));
     this.TireThree = new Tire(double.Parse(t3Pressure), int.Parse(t3Age));
     this.TireFour = new Tire(double.Parse(t4Pressure), int.Parse(t4Age));
 }
예제 #4
0
 public Car(string model, Engine engine, Cargo cargo, List<Tier> tiers)
 {
     this.Model = model;
     this.Engine = engine;
     this.Cargo = cargo;
     this.Tiers = tiers;
 }