Example #1
0
        public static void Main()
        {
            Drive Drive  = new Drive();
            int   number = int.Parse(Console.ReadLine());

            for (int i = 0; i < number; i++)
            {
                string[] input                 = Console.ReadLine().Split();
                string   model                 = input[0];
                double   fuelAmount            = double.Parse(input[1]);
                double   fuelConsumptionFor1km = double.Parse(input[2]);
                double   distanceTraveled      = 0;

                Cars currentCar = new Cars(model, fuelAmount, fuelConsumptionFor1km, distanceTraveled);
                Drive.AddCar(currentCar);
            }

            string command = Console.ReadLine();

            while (command != "End")
            {
                string[] input      = command.Split();
                string   model      = input[1];
                double   amountOfKm = double.Parse(input[2]);

                if (!Drive.IsWhetherTheCarCanMoveThatDistance(model, amountOfKm))
                {
                    Console.WriteLine("Insufficient fuel for the drive");
                }
                command = Console.ReadLine();
            }
            foreach (var item in Drive.Cars)
            {
                Console.WriteLine($"{item.Model} {item.FuelAmount:f2} {item.DistanceTraveled}");
            }
        }
Example #2
0
 public void AddCar(Cars currentCar)
 {
     Cars.Add(currentCar);
 }