public bool FuelingVehicle(string i_LicenseNumber, eFuel i_Fual, int i_AmountToFaul) { if (!VehicleInGarage(i_LicenseNumber)) { throw new ArgumentNullException("This Vehicle doesn't exist in the garage \n"); } UserDetails currentUserDetails = m_GarageList[i_LicenseNumber]; Vehicle vehicleToFaul = currentUserDetails.Vehicle; Engine engineToFaul = vehicleToFaul.VehicleEngine; FuelEngine fuelEngine = engineToFaul as FuelEngine; if (fuelEngine == null) { throw new ArgumentException("This is not fuel car \n"); } eFuel correctFuel = fuelEngine.FuelType; if (!correctFuel.Equals(i_Fual)) { throw new ArgumentException("You entered wrong fuel type"); } bool tryToFuel = fuelEngine.Fill(i_AmountToFaul, i_Fual); return(tryToFuel); }
public void Charge(float i_Liters, eFuel i_FuelType) { float expectedAmountOfFuel = i_Liters + m_CurrentCampacity; if (!i_FuelType.Equals(m_FuelType)) { throw new ArgumentException("You are trying to add wrong fuel to the vehicle"); } else if (m_CurrentCampacity < v_MinCampacity || r_MaxCampacity < expectedAmountOfFuel) { throw new ValueOutOfRangeException(0, r_MaxCampacity - m_CurrentCampacity, expectedAmountOfFuel); } else { m_CurrentCampacity = expectedAmountOfFuel; } }