예제 #1
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()));
     }
 }
예제 #2
0
        public override string ToString()
        {
            return(string.Format(
                       @"Current amount of fuel in liters:{0}
Type of fuel:{1}",
                       base.ToString(),
                       m_FuelLType.ToString()));
        }
예제 #3
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Fuel Type : " + m_FuelType.ToString());

            return(stringBuilder.ToString());
        }
예제 #4
0
        public override string ToString()
        {
            string RegularEnergyDetails = "Fuel type: " + r_FuleType.ToString() + System.Environment.NewLine;

            RegularEnergyDetails += "Full tank: " + r_FullTank.ToString() + System.Environment.NewLine;
            RegularEnergyDetails += "Litters left in tank: " + m_AmountOfLittersLeftInTank.ToString() + System.Environment.NewLine;
            return(RegularEnergyDetails);
        }
예제 #5
0
파일: Fuel.cs 프로젝트: NoamMani/Garage
        public string GetFuelDetails()
        {
            string fuelDetails = string.Format(
                @"Fuel type: {0} 
Current fuel amount: {1}",
                m_FuelType.ToString(),
                m_CurrentFuelAmount.ToString());

            return(fuelDetails);
        }
예제 #6
0
파일: FuelTank.cs 프로젝트: YoniME/DN-EX3
        public override string GetEnergySourceDetails()
        {
            StringBuilder fuelTankDetails = new StringBuilder();

            fuelTankDetails.AppendFormat("Type of energy source: Fuel{0}", Environment.NewLine);
            fuelTankDetails.AppendFormat("Max amount of fuel in tank: {0}{1}", MaxEnergySourceCapacity, Environment.NewLine);
            fuelTankDetails.AppendFormat("Current amount of fuel in tank: {0}{1}", RemainingEnergy, Environment.NewLine);
            fuelTankDetails.AppendFormat("Type of fuel: {0}{1}", m_FuelType.ToString(), Environment.NewLine);

            return(fuelTankDetails.ToString());
        }
예제 #7
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat(
                @"EnergyPercentage : {0}% 
Fuel Type : {1}", string.Format("{0:0.00}", EnergyPrecentLeft), m_FuelType.ToString());
            stringBuilder.AppendLine();

            return(stringBuilder.ToString());
        }
예제 #8
0
        public override string ToString()
        {
            string basesString = base.ToString();

            basesString += string.Format(
                format: @"
Fuel Type: {0}",
                m_FuelType.ToString());

            return(basesString);
        }
예제 #9
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());
     }
 }
예제 #10
0
 public void FillFuel(float i_AmountOfFuelToFill, eFuelType i_FuelType)
 {
     if (i_FuelType == m_FuelLType)
     {
         ChargeEneregy(i_AmountOfFuelToFill);
     }
     else
     {
         throw new ArgumentException(i_FuelType.ToString() + " is not matching the vehicle fuel type");
     }
 }
예제 #11
0
        public override string ToString()
        {
            string fuelData = string.Format(
                @"Fuel Type: {0}
Current amount of fuel: {1}
Max amount of fuel: {2}",
                r_FuelType.ToString(),
                CurrentCapacity,
                MaxCapacity);

            return(fuelData);
        }
예제 #12
0
        public override string ToString()
        {
            string details = string.Format(
                @"
Fuel type: {0}
Current liter fuel: {1}
Maximum liter fuel: {2}",
                r_FuelType.ToString(),
                m_CurrentEnergy,
                r_MaxEnergy);

            return(details + base.ToString());
        }
예제 #13
0
        public override string EngineInformation()
        {
            string correntEnergyLevelMessage;
            string maxEnergyLevelMessage;
            string TypeEnergyMessage;

            correntEnergyLevelMessage = "Corrent Energy Level " + CurrentEnergyStatus.ToString() + " Liters";
            maxEnergyLevelMessage     = "Max Energy Level " + MaxEnergyCapacity.ToString() + " Liters";
            TypeEnergyMessage         = "Fuel Type: " + r_FuelType.ToString();
            string fuelEngineInformation = string.Format("{0}\n{1}\n{2}", correntEnergyLevelMessage, maxEnergyLevelMessage, TypeEnergyMessage);

            return(fuelEngineInformation);
        }
        public void Recharge(float i_AmountToRecharge, eFuelType i_FuelType)
        {
            bool isProperFuelType = false;

            isProperFuelType = i_FuelType == m_EngineFuelType;
            if (!isProperFuelType)
            {
                throw new ArgumentException(string.Format("Not correct fuel type. needs to be {0}",
                                                          m_EngineFuelType.ToString()));
            }

            rechargeEnergy(i_AmountToRecharge);
        }
예제 #15
0
        public void AddFuel(float i_EnergyToAdd, eFuelType i_FuelType)
        {
            if ((i_EnergyToAdd + m_EnergyLeft) > m_MaxEnergy || i_EnergyToAdd < m_MinEnergy)
            {
                throw new ValueOutOfRangeException(m_MaxEnergy, m_MinEnergy, "Fuel");
            }

            if (i_FuelType != m_FuelType)
            {
                throw new ArgumentException(string.Format("Wrong fuel type! Fuel Type should be {0}", m_FuelType.ToString()));
            }

            m_EnergyLeft += i_EnergyToAdd;
        }
예제 #16
0
        public void RefuelVehicle(string i_LicenseNum, float i_FuelAmount, eFuelType i_FuelType)
        {
            if (Enum.IsDefined(typeof(eFuelType), i_FuelType))
            {
                throw new Exception("Not available Fuel");
            }

            if (!r_WorkCards.TryGetValue(i_LicenseNum, out Client Client))
            {
                throw new Exception("Vehicle doesn't exists");
            }

            Client.Vehicle.FillEnergy(i_FuelAmount, i_FuelType.ToString());
        }
예제 #17
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());
            }
        }
예제 #18
0
        public override string ToString()
        {
            string enginePropertiesStr = string.Format(
                @"
Fuel Engine Statistics:
------------------------
Fuel Type:           {0}
Current Fuel amount: {1}
Max Fuel Amount:     {2}
Fuel Left:           {3}%",
                r_FuelType.ToString(),
                CurrentEnergyAmount,
                MaxEnergyAmount,
                RemainingEnergyPercentage);

            return(enginePropertiesStr);
        }
예제 #19
0
 public override string ToString()
 {
     return(string.Format("Engine type: {0}{1}Fuel amount: {2}{1}Fuel Type: {3}{1}", m_EngineType.ToString(), System.Environment.NewLine, m_CurrentPowerAmount, m_FuelType.ToString()));
 }
예제 #20
0
 public WrongFuelTypeException(eFuelType i_WrongFuelType, eFuelType i_AppropriateFuelType)
     : base(string.Format("{0} is not the appropriate fuel, it has to be {1}",
                          i_WrongFuelType.ToString(), i_AppropriateFuelType.ToString()))
 {
 }
 public FuelMismatchException(eFuelType i_RequiredFuelType)
     : base("Engine required fuel of type " + i_RequiredFuelType.ToString())
 {
 }
예제 #22
0
 public void Refuel(eFuelType i_Type, float i_FuelAmountToAdd)
 {
     if (i_Type == m_FuelType)
     {
         if (m_CurrentFuelAmount + i_FuelAmountToAdd <= r_MaxFuelAmount)
         {
             m_CurrentFuelAmount += i_FuelAmountToAdd;
         }
         else
         {
             throw new ValueOutOfRangeException(0, r_MaxFuelAmount - m_CurrentFuelAmount, "i_FuelAmountToAdd");
         }
     }
     else
     {
         throw new ArgumentException(string.Format("the {0} is inValid For this Vehicle", i_Type), i_Type.ToString());
     }
 }
예제 #23
0
파일: Gasolin.cs 프로젝트: sigalbi/Garage
 public override void GetDetailesEngine(List <string> io_listOfDetailes)  // this function add the gasolin engine detailes to the list
 {
     io_listOfDetailes.Add(string.Format("Type of fule :{0}", m_fuelType.ToString()));
     io_listOfDetailes.Add(string.Format("Max fule :{0}", MaxEngineQuantity.ToString()));
     io_listOfDetailes.Add(string.Format("Current fuel:{0}", CurrentEngineQuantity.ToString()));
 }
예제 #24
0
 public override void GetDetails(List <string> i_VehicleDetails)
 {
     base.GetDetails(i_VehicleDetails);
     i_VehicleDetails.Add("Fuel Type: " + m_FuelType.ToString());
 }
 public FuelMismatchException(eFuelType i_RequiredFuelType) :
     base("Engine required fuel of type " + i_RequiredFuelType.ToString())
 {
 }