public static void AddGasToVehicle() { float gasAmountToAdd; string gasAmountAsString; Console.WriteLine("Please enter licence number"); string license = Console.ReadLine(); Console.WriteLine("Please insert a few liters of fuel to fill: "); gasAmountAsString = Console.ReadLine(); FuelEnergy.eTypeOfFuel ChoiceOfFuelType = SelectFuelType(); if (!float.TryParse(gasAmountAsString, out gasAmountToAdd)) { throw new FormatException(); } ObjectOfGarage.AddFulToVehicle(license, gasAmountToAdd, ChoiceOfFuelType); Console.WriteLine("The fuel refill succeeded"); }
public void AddFulToVehicle(string i_LicenseNumber, float i_AmountOfGaslToFill, FuelEnergy.eTypeOfFuel i_TypeOfGas) { NewVehiclesInTheGarage VehicleInGarage; VehicleInGarage = getVehicleFromDictionary(i_LicenseNumber); if (VehicleInGarage == null) { throw new VehicleNotFoundException(i_LicenseNumber); } if (!(VehicleInGarage.Vehicle.VehicleEnergy is FuelEnergy)) { throw new ArgumentException(); } (VehicleInGarage.Vehicle.VehicleEnergy as FuelEnergy).RefuelingOperation(i_AmountOfGaslToFill, i_TypeOfGas); }