public void CheckFuelType(eFuelType i_FuelType) { if (!i_FuelType.Equals(m_FuelType)) { throw new ArgumentException(); } }
internal virtual void Refueling(float i_FuelToAdd, eFuelType i_VehicleFuelType) { if (m_FuelType.Equals(i_VehicleFuelType)) { if (m_VehicleData.CurrentEnergy + i_FuelToAdd <= m_VehicleData.MaxEnergy) { m_VehicleData.CurrentEnergy += i_FuelToAdd; m_VehicleData.EnergyLeft = m_VehicleData.CurrentEnergy / m_VehicleData.MaxEnergy; } else { string message = "Fail refueling the vehicle"; throw new ValueOutOfRangeException( 0, m_VehicleData.MaxEnergy - m_VehicleData.CurrentEnergy, message); } } else { throw new ArgumentException( string.Format( format: "You cannot add {0} to this vehicle", i_VehicleFuelType.ToString())); } }
/// <summary> /// receives the quantity of fuel /// to add to the tank without exceeding /// from maximum fuel capacity and checking /// if the fuel type fits the car's type /// </summary> /// <param name="i_energyToAdd"></param> /// <param name="i_Fueltype"></param> public void FuelAddition(eFuelType i_Fueltype, float i_EnergyToAdd) { if (!i_Fueltype.Equals(m_FuelType)) { throw new ArgumentException(); } EnergyAddition(i_EnergyToAdd); }
internal void Charge(float i_Liters, eFuelType i_FuelType) { if (r_FuelType.Equals(i_FuelType)) { base.Charge(i_Liters); } else { throw new ArgumentException(i_FuelType.ToString()); } }
public void FillFuel(eFuelType i_FuelType, float i_AmountOfFuelToFill) { if (i_FuelType.Equals(this.r_FuelType)) { RefillEnergySource(i_AmountOfFuelToFill, !true); } else { throw new ArgumentException("Fuel type does not match!"); } }
private bool isSameFuelType(eFuelType i_FuelType) { bool result = false; if (i_FuelType.Equals(FuelType)) { result = true; } return(result); }
public void FillFuel(float i_AmountFuelToAdd, eFuelType i_FuelType) { if (!i_FuelType.Equals(m_FuelType)) { throw new ArgumentException("Wrong fuel type"); } else { FillEnergy(i_AmountFuelToAdd); } }
public void FuelUp(float i_FuelToAdd, eFuelType i_FuelType) { if (i_FuelType.Equals(m_FuelType)) { if (m_CurrentFuelCapacity + i_FuelToAdd > m_MaxFuelCapacity) { throw new ValueOutOfRangeException(new Exception(), 0, m_MaxFuelCapacity); } m_CurrentFuelCapacity += i_FuelToAdd; } else { throw new WrongFuelException(new Exception(), i_FuelType.ToString(), m_FuelType.ToString()); } }
internal void Refuel(float i_AmountOfFuelToAdd, eFuelType i_FuelType) { if (i_FuelType.Equals(m_fuelType)) { if (i_AmountOfFuelToAdd + m_PowerLeft > m_MaximumPowerPossible) { throw new ValueOutOfRangeException(0, m_MaximumPowerPossible - m_PowerLeft); } else { m_PowerLeft = m_PowerLeft + i_AmountOfFuelToAdd; } } else { throw new ArgumentException(); } }
/// <summary> /// A method that receives how much more fuel to add, and changes the /// amount of fuel, if the fuel type is correct, and the fuel tank /// is less than full. /// </summary> public bool Refuel(float i_Amount, eFuelType i_FuelType) { bool refuled = true; if (!i_FuelType.Equals(FuelType)) { refuled = !refuled; throw new ArgumentException(this.GetType().Name + "Wrong fuel type"); } else { try { Fill(i_Amount); } catch (ValueOutOfRangeException) { refuled = !refuled; } } return(refuled); }
private bool isSameFuelType(eFuelType i_FuelType) { bool result = false; if (i_FuelType.Equals(FuelType)) { result = true; } return result; }