示例#1
0
        private void fuelGasVehicleMenu()
        {
            try
            {
                string registrationNumber = string.Empty;
                float  fuelToAddAmount    = 0;

                registrationNumber = getGasCarToFuelRegNum();
                fuelToAddAmount    = getFuelAmountFromUser();

                m_Garage.RefillVehicle(registrationNumber, fuelToAddAmount);

                Console.WriteLine("Refueling was done successfully.");
            }
            catch (ArgumentException i_ArgumentException)
            {
                if (i_ArgumentException.Message == "Invalid_Fuel_Type")
                {
                    Console.WriteLine("Error: the fuel type inserted does not match the vehicle.");
                }
                else if (i_ArgumentException.Message == "Not_Fuelable_Vehicle")
                {
                    Console.WriteLine("Error: Vehicle is elctric therefore not fuelable.");
                }
                else if (i_ArgumentException.Message == "Vehicle_Not_Exist")
                {
                    Console.WriteLine("There is no vehicle in the garage with the entered registaration number.");
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("Error: Input format does not match the format type required.{0}", Environment.NewLine);
            }
            catch (ValueOutOfRangeException i_ValueOutOfRangeException)
            {
                Console.WriteLine(i_ValueOutOfRangeException.Message);
            }
        }