IPetrov007

07_SpeedRacing

Jul 2nd, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _07_SpeedRacing
  6. {
  7. public class SpeedRacing
  8. {
  9. public static void Main()
  10. {
  11. var cars = new List<Car>();
  12. var num = int.Parse(Console.ReadLine());
  13. for (int i = 0; i < num; i++)
  14. {
  15. var inputLine = Console.ReadLine().Split();
  16. var model = inputLine[0];
  17. var fuelAmmaunt = int.Parse(inputLine[1]);
  18. var fuelConsumption = double.Parse(inputLine[2]);
  19.  
  20. var car = new Car(model, fuelAmmaunt, fuelConsumption);
  21. cars.Add(car);
  22. }
  23. string inputCommands;
  24. while ((inputCommands = Console.ReadLine()) != "End")
  25. {
  26. var comands = inputCommands.Split();
  27. var carModel = comands[1];
  28. var amaunOfKm = int.Parse(comands[2]);
  29.  
  30. Car currentCar = cars.Where(c => c.Model == carModel).ToList().First();
  31. currentCar.IsMove(amaunOfKm);
  32. }
  33.  
  34. foreach (var car in cars)
  35. {
  36. Console.WriteLine($"{car.Model} {car.Fuel:f2} {car.Distance}");
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment