예제 #1
0
    static void Main()
    {
        int        n    = int.Parse(Console.ReadLine());//amount of cars
        List <Car> cars = new List <Car>();

        for (int i = 0; i < n; i++)
        {
            string[] info          = Console.ReadLine().Split(' ').ToArray();
            string   model         = info[0];
            int      engineSpeed   = int.Parse(info[1]);
            int      enginePower   = int.Parse(info[2]);
            int      cargoWeight   = int.Parse(info[3]);
            string   cargoType     = info[4];
            double   tiereOnePre   = double.Parse(info[5]);
            int      tiereOneAge   = int.Parse(info[6]);
            double   tiereTwoPre   = double.Parse(info[7]);
            int      tiereTwoAge   = int.Parse(info[8]);
            double   tiereThreePre = double.Parse(info[9]);
            int      tiereThreeAge = int.Parse(info[10]);
            double   tiereFourPre  = double.Parse(info[11]);
            int      tiereFourAge  = int.Parse(info[12]);

            Engine       engine     = new Engine(engineSpeed, enginePower);
            Cargo        cargo      = new Cargo(cargoWeight, cargoType);
            Tiere        tiereOne   = new Tiere(tiereOnePre, tiereOneAge, 1);
            Tiere        tiereTwo   = new Tiere(tiereTwoPre, tiereTwoAge, 2);
            Tiere        tiereThree = new Tiere(tiereThreePre, tiereThreeAge, 3);
            Tiere        tiereFour  = new Tiere(tiereFourPre, tiereFourAge, 4);
            List <Tiere> tieres     = new List <Tiere> {
                tiereOne, tiereTwo, tiereThree, tiereFour
            };
            Car car = new Car(model, engine, cargo, tieres);

            cars.Add(car);
        }
        string command = Console.ReadLine();

        if (command == "fragile")
        {
            var carsFragile =
                cars.Where(c => c.Cargo.Type == "fragile").Where(t => t.Tieres.Any(ti => ti.Pressure < 1));
            foreach (var car in carsFragile)
            {
                Console.WriteLine(car.Model);
            }
        }
        else//flamable
        {
            var carsFlamable = cars.Where(c => c.Cargo.Type == "flamable").Where(e => e.Engine.Power > 250);
            foreach (var car in carsFlamable)
            {
                Console.WriteLine(car.Model);
            }
        }
    }
예제 #2
0
파일: Form1.cs 프로젝트: eier/sbc
 // Wrapper for ThreadStart madness.
 private void startJob(Tiere t)
 {
     ThreadStart ts = new ThreadStart(t.work);
     Thread th = new Thread(ts);
     th.Start();
 }
예제 #3
0
파일: Form1.cs 프로젝트: eier/sbc
 // Wrapper for ThreadStart madness.
 private void startJob(Tiere t)
 {
     ThreadStart ts = new ThreadStart(t.work);
     Thread th = new Thread(ts);
     th.Start();
 }
예제 #4
0
 public void Add(T tier)
 {
     Tiere.Add(tier);
 }