Advertisement
Desislav74

Untitled

Oct 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace RawData
  7. {
  8. public class StartUp
  9. {
  10.  
  11.  
  12. static void Main(string[] args)
  13. {
  14. List<Car> cars = new List<Car>();
  15.  
  16. int count = int.Parse(Console.ReadLine());
  17. for (int i = 0; i < count; i++)
  18. {
  19. string[] inputInfo = Console.ReadLine()
  20. .Split()
  21. .ToArray();
  22. string model = inputInfo[0];
  23.  
  24. int engineSpeed = int.Parse(inputInfo[1]);
  25. int enginePower = int.Parse(inputInfo[2]);
  26.  
  27.  
  28.  
  29. int cargoWeight = int.Parse(inputInfo[3]);
  30. string cargoType = inputInfo[4];
  31.  
  32.  
  33.  
  34. Tire[] tires = new Tire[4];
  35. int counter = 0;
  36. for (int tireIndex = 5; tireIndex < inputInfo.Length; tireIndex += 2)
  37. {
  38. double currentTirePressure = double.Parse(inputInfo[tireIndex]);
  39. int currentTireAge = int.Parse(inputInfo[tireIndex + 1]);
  40.  
  41. Tire tire = new Tire(currentTirePressure, currentTireAge);
  42. tires[counter++] = tire;
  43. }
  44.  
  45.  
  46. Engine engine = new Engine(engineSpeed, enginePower);
  47. Cargo cargo = new Cargo(cargoWeight, cargoType);
  48. Car car = new Car(model, engine, cargo, tires);
  49. cars.Add(car);
  50. }
  51. string cargoInfo = Console.ReadLine();
  52. if (cargoInfo == "flamable")
  53. {
  54.  
  55. cars.Where(x => x.Engine.EnginePower > 250 && x.Cargo.CargoType == "flamable")
  56. .ToList()
  57. .ForEach(x => Console.WriteLine(x.Model));
  58. }
  59. else if (cargoInfo == "fragile")
  60. {
  61.  
  62. cars.Where(x => x.Cargo.CargoType == "fragile" && x.Tires.Any(p => p.TirePressure < 1))
  63. .ToList()
  64. .ForEach(x => Console.WriteLine(x.Model));
  65.  
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement