private void fuelVehicle() { try { Console.Clear(); string licnsenumber = getLicenseNumber(); eTypeFuel typeFuel = reciveTypeFuel(); float amountOfFuel = getPositiveFloatInput("Enter amount of fuel"); m_Garge.FillRegularVehicle(licnsenumber, typeFuel, amountOfFuel); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } catch (FormatException fe) { Console.WriteLine(fe.Message); } catch (ValueOutOfRangeException vore) { Console.WriteLine(vore.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void FillRegularVehicle(string i_LicenseId, eTypeFuel i_FuelType, float i_AmountToFill) { Customer customer = TryToGetCustomer(i_LicenseId); FuelEnergySystem fuelEnergy = customer.Vehicle.EnergySystem as FuelEnergySystem; if (fuelEnergy != null) { fuelEnergy.FillFuel(i_AmountToFill, i_FuelType); } else { throw new FormatException("The Object doesn't have fuel system"); } }
public void FillFuel(float i_FuelToFill, eTypeFuel i_FuelType) { if (i_FuelType == m_FuelType) { if (i_FuelToFill + m_CurrentEnergy <= m_EnergyCapacity && i_FuelToFill >= 0 && i_FuelType == m_FuelType) { m_CurrentEnergy += i_FuelToFill; } else { throw new ValueOutOfRangeException(m_EnergyCapacity - m_CurrentEnergy, 0); } } else { throw new ArgumentException("Fuel type does't match"); } }
public FuelEnergySystem(eTypeFuel i_FuelType, float i_EnergyCapcity, float i_CurrentEnergy) : base(i_EnergyCapcity, i_CurrentEnergy) { m_FuelType = i_FuelType; }