internal void AddGasToVehicle(float i_AmountGassToAdd, eTypeOfGas i_TypeOfGass) { try { Gas gas = m_Resourse as Gas; gas.RefuelingVehicle(i_AmountGassToAdd, i_TypeOfGass); UdatePercentageResourceLeft(gas.CurrentAmountOfResource, gas.MaximalAmountOfResource); } catch (InvalidCastException) { throw new ArgumentException("Vehicle resourse isn't gas"); } }
internal void RefuelingVehicle(float i_AmountGasToAdd, eTypeOfGas i_TypeOfGas) { float totalAmoutOfGas = CurrentAmountOfResource + i_AmountGasToAdd; if (m_TypeOfGas.Equals(i_TypeOfGas)) { if (totalAmoutOfGas <= MaximalAmountOfResource && i_AmountGasToAdd >= Constants.k_MinimalValue) { CurrentAmountOfResource += i_AmountGasToAdd; } else { throw new ValueOutOfRangeException(Constants.k_MinimalValue, MaximalAmountOfResource - CurrentAmountOfResource); } } else { throw new ArgumentException("This type of gas is not matching"); } }
public void RefuelingVehicle(string i_LicenseNumber) { if (r_Garage.VeliclesInGarage[i_LicenseNumber].Resourse is Electric) { Console.WriteLine("The vehicle resource isn't gas!"); return; } Console.WriteLine("Enter the amount of gas for refueling the vehicle"); float amountGassToAdd = 0f; bool parseSucces = InputValidation.InputIsFloat(Console.ReadLine(), ref amountGassToAdd); if (!parseSucces) { throw new FormatException("Format exception has occured"); } eTypeOfGas typeOfGas = (r_Garage.VeliclesInGarage[i_LicenseNumber].Resourse as Gas).TypeOfGas; r_Garage.RefuelingWithGas(i_LicenseNumber, typeOfGas, amountGassToAdd); }
public void RefuelingWithGas(string i_LicenseNumber, eTypeOfGas i_TypeOfGas, float i_AmountGassToAdd) { GetVehicleByLicenseNumber(i_LicenseNumber).AddGasToVehicle(i_AmountGassToAdd, i_TypeOfGas); }