Exemple #1
0
        public static void setDistance(int n)
        {
            bool running = true;

            for (int i = 0; running && i < n; i++)
            {
                running = FuelGauge.burnFuel();

                if (running == true)
                {
                    Console.WriteLine($"Km: {distance} \t\tFuel: {FuelGauge.getLiters():n2} L");
                    distance++;
                }
                if (distance == 1000)
                {
                    distance = 0;
                }
            }
        }
Exemple #2
0
        static void selectMenu()
        {
            bool   invalidInput = true;
            string choice       = " ";
            double currentfuel  = FuelGauge.getLiters();

            while (invalidInput)
            {
                try
                {
                    DisplayMenu();
                    Console.Write("Option: ");
                    choice = Console.ReadLine();

                    switch (choice)
                    {
                    case "0":
                        Console.WriteLine("Good-bye - please come again ...");
                        invalidInput = false;
                        break;

                    case "1":
                        currentfuel += FuelGauge.setFuel();
                        break;

                    case "2":
                        Odometer.setDistance(driveCar());
                        break;

                    default:
                        Console.WriteLine($"Please enter a valid number between 0 and 2 inclusive");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: {ex.Message}");
                }
            }
        }