예제 #1
0
 public void CheckFuelType(eFuelType i_FuelType)
 {
     if (!i_FuelType.Equals(m_FuelType))
     {
         throw new ArgumentException();
     }
 }
예제 #2
0
 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()));
     }
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
 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!");
     }
 }
예제 #6
0
        private bool isSameFuelType(eFuelType i_FuelType)
        {
            bool result = false;

            if (i_FuelType.Equals(FuelType))
            {
                result = true;
            }

            return(result);
        }
예제 #7
0
 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);
     }
 }
예제 #8
0
        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());
            }
        }
예제 #9
0
 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();
     }
 }
예제 #10
0
        /// <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);
        }
예제 #11
0
        private bool isSameFuelType(eFuelType i_FuelType)
        {
            bool result = false;
            if (i_FuelType.Equals(FuelType))
            {
                result = true;
            }

            return result;
        }