public void RefuelVehicle(CustomerCard i_Cutomer, float i_Amount, string i_TypeStr) { eFuelType eType = FromStringToVehicleFuelTypeEnum(i_TypeStr); FuelEnergySource fuelSource = i_Cutomer.Vehicle.EnergySource as FuelEnergySource; if (fuelSource.FuelType == eType) { fuelSource.Load(i_Amount); } else { throw new ArgumentException("Fuel type is not suitable to this vehicle"); } }
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); }
private static EnergySource getEnergySource(eVehicleType i_VehicleType, eEnergySourceType i_EnergySourceType, float i_CurrentEnergyAmount) { EnergySource energySource; switch (i_EnergySourceType) { case eEnergySourceType.Fuel: energySource = new FuelEnergySource(i_CurrentEnergyAmount, getFuelEnergyFillingInfoByVehicleType(i_VehicleType)); break; case eEnergySourceType.Electricity: energySource = new ElectricEnergySource(i_CurrentEnergyAmount, getElectricityEnergyFillingInfoByVehicleType(i_VehicleType)); break; default: throw new ArgumentOutOfRangeException("i_EnergySourceType"); } return(energySource); }
public void RefuelVehicle(CustomerCard i_Customer, float i_Amount, string i_TypeStr) { eFuelType fuelType; if (IsFuelType(i_TypeStr, out fuelType) == true) { FuelEnergySource fuelSource = i_Customer.Vehicle.EnergySource as FuelEnergySource; if (fuelSource.FuelType == fuelType) { fuelSource.Load(i_Amount); i_Customer.Vehicle.UpdateEnergyPercentageLeft(); if (r_ConnectedToDB == true) { addEnergyDBactions(i_Customer); } } else { throw new ArgumentException("Fuel type is not suitable to this vehicle"); } } }
public bool IsFuelType(string i_Type) { return(FuelEnergySource.IsFuelType(i_Type)); }
public string[] GetFuelTypes() { return(FuelEnergySource.GetFuelTypes()); }