internal void fillGas(Enums.eFuelType i_FuelType, float i_GasToFill) { if (i_FuelType == r_FuelType) { if (i_GasToFill >= 0) { if (CurrentCapacity + i_GasToFill <= MaxCapacity) { CurrentCapacity += i_GasToFill; } else { throw new ValueOutOfRangeException(0, MaxCapacity - CurrentCapacity, "The ammount of gas to fill entered is too high and exceeds the max tank capacity!"); } } else { throw new ArgumentException("The ammount of gas to fill is negative!"); } } else { throw new ArgumentException("Wrong fuel type for vehical!"); } }
private void refuel() { try { Enums.eFuelType fuelType = getEnumValueFromUserByType <Enums.eFuelType>("Select fuel type:"); float amountToRefill = getFloatUserInput("Select amount to refuel:"); string licensePlate = getInGarageLicensePlate(); r_GarageManager.RefillFuel(licensePlate, fuelType, amountToRefill); writeSuccessMessage("Vehicle is refueled!"); } catch (ArgumentException i_ArgumentException) { writeExceptionMessage("One or more of the arguments are wrong.", i_ArgumentException); } }
public void RefillFuel(string i_LicensePlate, Enums.eFuelType i_FuelType, float i_Amount) { Vehicle theVehicle = getVehicleInGarage(i_LicensePlate); FuelEnergySource fuelEnergySource = theVehicle.EnergySource as FuelEnergySource; if (fuelEnergySource == null) { throw new ArgumentException("license plate doesn't belong to fuel vehicle"); } bool isCorrectFuelType = fuelEnergySource.IsCorrectFuelType(i_FuelType); if (!isCorrectFuelType) { throw new ArgumentException("fuel type is incorrect"); } theVehicle.FillEnergy(i_Amount); }
public bool IsCorrectFuelType(Enums.eFuelType i_FuelType) { return(FuelFillingInfo.FuelType == i_FuelType); }
public FuelFillingInfo(Enums.eFuelType i_FuelType, float i_MaximumEnergyFillingAmount) : base(i_MaximumEnergyFillingAmount) { r_FuelType = i_FuelType; }
public GasEngine(Enums.eFuelType i_FuelType, float i_MaxGasTankCapacity) : base(i_MaxGasTankCapacity) { r_FuelType = i_FuelType; }
public void RefuelVehical(VehicalInformation i_VehicalToRefuel, Enums.eFuelType i_FuelType, float i_GasToFill) { if (i_VehicalToRefuel.Vehical.Engine is GasEngine gasVehicalToRefuel) { gasVehicalToRefuel.fillGas(i_FuelType, i_GasToFill); } else { throw new ArgumentException("Cannot refuel a vehical that is not run by gas!"); } }