Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Problem_6._Speed_Racing
- {
- public class StartUp
- {
- static void Main()
- {
- int numberOfcars = int.Parse(Console.ReadLine());
- var cars = new List<Car>();
- for (int i = 0; i < numberOfcars; i++)
- {
- var carInfo = Console.ReadLine().Split().ToArray();
- string model = carInfo[0];
- double fuelAmount = double.Parse(carInfo[1]);
- double fuelConsumptionPerKilometer = double.Parse(carInfo[2]);
- Car car = new Car(model, fuelAmount, fuelConsumptionPerKilometer);
- cars.Add(car);
- }
- var input = Console.ReadLine();
- while (input != "End")
- {
- var driveInfo = input.Split().ToArray();
- string model = driveInfo[1];
- double amountOfKm = double.Parse(driveInfo[2]);
- cars.Where(c => c.Model == model).ToList().ForEach(c => c.CanDriveTheDistance(amountOfKm));
- input = Console.ReadLine();
- }
- foreach (var car in cars)
- {
- Console.WriteLine($"{car.Model} {car.FuelAmount:f2} {car.TravelledDistance}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement