public void FillFuelVehicle()
        {
            float  amountOfFuel;
            int    typeOfFuel;
            string licenseNumber = GetLicenseNumber();
            bool   vehicleExist  = m_Garage.VehicleExistInGarage(licenseNumber);

            if (vehicleExist)
            {
                amountOfFuel = m_UI.GetFloatInput();
                m_UI.PrintMessage(Messages.AskingTypeOfFuel);
                typeOfFuel = m_UI.GetIntInRange(1, 4);
                m_Garage.FillFuel(licenseNumber, amountOfFuel, (eFuelType)typeOfFuel);
            }
            else
            {
                string errMsg = string.Format("Vehicle {0} is not existing in the garage", licenseNumber);
                throw new ArgumentException(errMsg);
            }
        }
Esempio n. 2
0
        public void FillFuelInVehicle()
        {
            const string k_EnterFuelAmount = "Please enter the desired fuel amount to fill:";
            const string k_ChooseFuelType  = "Please choose fuel type:";
            float        amountOfFuel;
            int          typeOfFuel;
            string       licenseNumber = r_Ui.GetLicenseNumber();
            bool         vehicleExist  = r_Garage.VehicleExistInGarage(licenseNumber);

            string[] fuelTypes = Enum.GetNames(typeof(VehiclesEnums.eFuelType));
            string   errorMsg  = string.Format(k_VehicleDoesntExist, licenseNumber, Environment.NewLine);

            if (vehicleExist)
            {
                r_Ui.PrintMessage(k_EnterFuelAmount);
                amountOfFuel = r_Ui.GetFloatInput();
                typeOfFuel   = r_Ui.GetNumberFromOptions(fuelTypes, k_ChooseFuelType);
                r_Garage.FillFuel(licenseNumber, amountOfFuel, (VehiclesEnums.eFuelType)typeOfFuel);
            }
            else
            {
                throw new ArgumentException(errorMsg);
            }
        }