Beispiel #1
0
        private void refuelfuelVehicle()
        {
            Console.WriteLine("Hello, please enter vehicle's License number in order to refuel:");
            string vehicleLicense = getNotEmptyInput();
            bool   carIsInGarage  = true;

            try
            {
                m_LogicManager.IsInGarage(vehicleLicense);
            }
            catch (FormatException)
            {
                Console.WriteLine("This vehicle License number not exsit in our garage, press enter for main menu");
                Console.ReadLine();
                carIsInGarage = false;
            }
            while (true & carIsInGarage)
            {
                Console.WriteLine(@"choose you'r vehicles fuel type:
(1) Soler
(2) Octan95
(3) Octan96
(4) Octan98");
                eFuelType fuelType = (eFuelType)int.Parse(getNumberInRange(1, 4, true));
                Console.WriteLine("What is the amount of fuel you waht to add?");
                float amountOfFuel = getFloatInput();
                try
                {
                    m_LogicManager.Addfuel(vehicleLicense, fuelType, amountOfFuel);
                    Console.WriteLine("It was done now {0} fueled with the amount you asked: {1}", vehicleLicense, amountOfFuel);
                    Console.ReadLine();
                    break;
                }
                catch (ValueOutOfRangeException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadLine();
                }
                catch (FormatException)
                {
                    Console.WriteLine("You trying to refuel a elctric engiane, please go to charge option at the main menu (option number 6)");
                    Console.ReadLine();
                    break;
                }
                catch (ArgumentException)
                {
                    Console.WriteLine(@"Your vehicle is not suppoting this type of fuel
want to try again?
(1) Yes
(2) No");
                    string userInput = getNumberInRange(1, 2, true);
                    if (userInput.Equals("2"))
                    {
                        Console.WriteLine("Thank you !");
                        Console.ReadLine();
                        break;
                    }
                }
            }
        }