Ejemplo n.º 1
0
 public void FuelVehicle(float i_AmountToAdd, Enums.eGasType i_GasType)
 {
     if (i_GasType == r_GasType)
     {
         addEnergy(i_AmountToAdd);
     }
     else
     {
         throw new ArgumentException("The chosen gas type doesn't match the car's gas type");
     }
 }
Ejemplo n.º 2
0
        public static void FuelVehicle(string i_LicsenseNumber, Enums.eGasType i_GasType, float i_GasToFuel)
        {
            Engine     engine     = getVehicleByLicenseNumber(i_LicsenseNumber).Vehicle.Engine;
            FuelEngine fuelEngine = engine as FuelEngine;

            if (fuelEngine != null)
            {
                fuelEngine.FuelVehicle(i_GasToFuel, i_GasType);
            }
            else
            {
                throw new ArgumentException("Vehicle has an electric engine");
            }
        }
Ejemplo n.º 3
0
 // Add fuel method, throws exception if the amount to add is larger then the max capacity, or the gas type is not valid
 public void AddFuel(float i_FuelToAdd, Enums.eGasType i_GasType)
 {
     if (i_GasType != m_GasType)
     {
         throw new ArgumentException("{0} type do not match to this vehicle", i_GasType.ToString());
     }
     else if (i_FuelToAdd + m_CurrentCapacity > m_MaxCapacity)
     {
         throw new ValueOutOfRangeException("Fuel", k_MinAmountToAdd, m_MaxCapacity);
     }
     else
     {
         m_CurrentCapacity     += i_FuelToAdd;
         m_CapacityInPrecentege = (m_CurrentCapacity / m_MaxCapacity) * 100;
     }
 }
Ejemplo n.º 4
0
        // Add fuel in the vehicle to max, if vehicle not found throws exception
        public void AddFuel(string i_LicenseNumber, float i_FuelToAdd, Enums.eGasType i_GasType)
        {
            IsGarageEmpty();
            if (!(m_ListOfVehicles.ContainsKey(i_LicenseNumber)))
            {
                throw new Exception("We don't have this vehicle in our garage, sorry.");
            }

            Vehicle vehicle = m_ListOfVehicles[i_LicenseNumber];

            if (!(vehicle.MyEngine is FuelEngine))
            {
                throw new Exception("This is not a fuel driven car, please select another option");
            }
            else
            {
                (vehicle.MyEngine as FuelEngine).AddFuel(i_FuelToAdd, i_GasType);
            }
        }
Ejemplo n.º 5
0
 public FuelEngine(Enums.eGasType i_GasType, float i_CurrentEnergy, float i_MaxEnergy) : base(i_CurrentEnergy, i_MaxEnergy)
 {
     r_GasType = i_GasType;
 }