public void CheckingFuelTypeInput(string i_LicenseNumberToReful, string i_FuelType) { Vehicle vehicleToCheck; m_VehicleInTheGarage.TryGetValue(i_LicenseNumberToReful.GetHashCode(), out vehicleToCheck); if (vehicleToCheck.EnergySource is FuelTank) { FuelTank FuelTankTochek = vehicleToCheck.EnergySource as FuelTank; FuelType.eFuelType fuelTypeToFill = FuelType.ParseFromString(i_FuelType); if (FuelTankTochek._FuelType != fuelTypeToFill) { throw new ArgumentException(string.Format("The vehicle with the license number {0} does not support {1} fuel type.", i_LicenseNumberToReful, fuelTypeToFill.ToString())); } } }
public string RefuelingAVehicle(string i_LicenseNumberToReful, string i_FuelType, string i_AmountOfLitersToAdd) { string loadMessage; Vehicle vehicleToLoad; m_VehicleInTheGarage.TryGetValue(i_LicenseNumberToReful.GetHashCode(), out vehicleToLoad); if (vehicleToLoad.EnergySource is FuelTank) { FuelTank currentVehicleFuelTank = vehicleToLoad.EnergySource as FuelTank; currentVehicleFuelTank.Refueling(float.Parse(i_AmountOfLitersToAdd), FuelType.ParseFromString(i_FuelType));///check EXP caching loadMessage = string.Format("The vehicle {0} refueling was successful.", i_LicenseNumberToReful); } else { throw new ArgumentException(string.Format("The vehicle with the license number: {0} is electric vehicle.", i_LicenseNumberToReful)); } updatePrecentOfenergy(i_LicenseNumberToReful, i_AmountOfLitersToAdd); return(loadMessage); }