public static string AsText(eKindOfFuel i_eKindOfFuel)
        {
            string enumDescripton = "null";

            switch (i_eKindOfFuel)
            {
            case eKindOfFuel.Soler:
            {
                enumDescripton = "Soler";
                break;
            }

            case eKindOfFuel.Octan95:
            {
                enumDescripton = "Octan95";
                break;
            }

            case eKindOfFuel.Octan96:
            {
                enumDescripton = "Octan96";
                break;
            }

            case eKindOfFuel.Octan98:
            {
                enumDescripton = "Octan98";
                break;
            }
            }

            return(enumDescripton);
        }
예제 #2
0
 public override void FillUpEnergy(eKindOfFuel i_GivenFuelKind, float i_AmountToFill)
 {
     if (EnergyManager is FuelProperties fuelProperties)
     {
         fuelProperties.Fuel(i_AmountToFill, i_GivenFuelKind, sr_MaxGasTank);
     }
     else
     {
         throw new ArgumentException("Cannot fill up fuel in an electric vehicle.");
     }
 }
예제 #3
0
 private void refuelHandleVehicleExists(Customer i_RequestedCustomer, eKindOfFuel i_FuelType,
                                        float i_FuelQuantityToFillInLiter)
 {
     if (i_RequestedCustomer.Vehicle.EnergySource is Fuel)
     { // the vehicle energy source is fuel
         refuelHandleFuelVehicle(i_RequestedCustomer, i_FuelType, i_FuelQuantityToFillInLiter);
     }
     else
     {
         throw new ArgumentException(k_ErrVehicleEnergySourceNotMatch);
     }
 }
예제 #4
0
        //private void chargeHandleVehicleExists(Customer i_RequestedCustomer, float i_ChargingTimeInMinutes)
        //{
        //    if (i_RequestedCustomer.Vehicle.EnergySource is Electric)
        //    { // the vehicle energy source is electric
        //        chargeHandleElectricVehicle(i_RequestedCustomer, i_ChargingTimeInMinutes);
        //    }
        //    else
        //    {
        //        throw new ArgumentException(k_ErrVehicleEnergySourceNotMatch);
        //    }
        //}

        //צמצמתי הכל למעלה וזרקנו אקספשניין מהמקור אנרגיה חשמלי או דלק
        //private void chargeHandleElectricVehicle(Customer i_RequestedCustomer, float i_ChargingTimeInMinutes)
        //{
        //    Electric electricVehicle = i_RequestedCustomer.Vehicle.EnergySource as Electric;
        //    float ChargingTimeInHours = i_ChargingTimeInMinutes / 60; // convert minutes to hours

        //    if (electricVehicle.BatteryLeftInTheHours + ChargingTimeInHours <= electricVehicle.MaximumHourlyBattery)
        //    { // the requested charging time is valid
        //        electricVehicle.Charge(ChargingTimeInHours);
        //    }
        //    else
        //    {
        //        float maxChargingTimeInHours = electricVehicle.MaximumHourlyBattery
        //            - electricVehicle.BatteryLeftInTheHours;
        //        float minChargingTimeInHours = 0;

        //        throw new ValueOutOfRangeException(maxChargingTimeInHours, minChargingTimeInHours);
        //    }
        //}

        public void RefuelVehicle(string i_LicenseNumber, eKindOfFuel i_FuelType, float i_FuelQuantityToFillInLiter)
        {
            Customer requestedCustomer;
            bool     vehicleExists = m_Customers.TryGetValue(i_LicenseNumber, out requestedCustomer);

            if (vehicleExists)
            {
                refuelHandleVehicleExists(requestedCustomer, i_FuelType, i_FuelQuantityToFillInLiter);
            }
            else
            {
                throw new ArgumentException(k_ErrVehicleNotExists);
            }
        }
예제 #5
0
        private void refuelHandleFuelVehicle(Customer i_RequestedCustomer, eKindOfFuel i_FuelType,
                                             float i_FuelQuantityToFillInLiter)
        {
            Fuel fuelVehicle = i_RequestedCustomer.Vehicle.EnergySource as Fuel;

            if (fuelVehicle.KindOfFuel.Equals(i_FuelType))
            {  // the vehicle fuel type match the requested fuel type
                refuelHandleCorrectType(fuelVehicle, i_FuelQuantityToFillInLiter);
                i_RequestedCustomer.Vehicle.PercentageRemainingEnergy =
                    i_RequestedCustomer.Vehicle.EnergySource.GetCurrentEnergy();
            }
            else
            {
                throw new ArgumentException(k_ErrVehicleFuelNotMatch);
            }
        }
예제 #6
0
 internal void Fuel(float i_Amount, eKindOfFuel i_KindOfFuel, int i_MaxGasTank)
 {
     if (i_KindOfFuel == m_KindOfFuel)
     {
         if (i_Amount + CurrentEnergy <= MaxEnergyCapacity)
         {
             CurrentEnergy += i_Amount;
         }
         else
         {
             throw new ValueOutOfRangeException(MaxEnergyCapacity, 0, string.Format("The amount of fuel that was given exceeds the limit, the minimun value is: {0}, and the maximum value is: {1}", 0, i_MaxGasTank));
         }
     }
     else
     {
         throw new ArgumentException("The given fuel kind does not match the vehicle fuel kind.");
     }
 }
예제 #7
0
        private static void fuelVehicle()
        {
            const int k_MinNumToFill = 0;
            const int k_MinFuel      = 1;

            try
            {
                string      formatedFuelKinds = GrageData.GetEnumFormatedString(typeof(eKindOfFuel), out int numberOfFuelKinds);
                string      licenseNumber     = getStringFromUser("Please enter your license number");
                int         amountToFill      = getIntFromUser(k_MinNumToFill, int.MaxValue, "Please enter how much gas you would like to fill up.");
                eKindOfFuel kindOfFuel        = (eKindOfFuel)getIntFromUser(k_MinFuel, numberOfFuelKinds, string.Format("Please enter the kind of fuel you want to fill {0}{1}", Environment.NewLine, formatedFuelKinds));
                Vehicle     foundVehicle      = sr_GrageData.FindByLicenseNumber(licenseNumber);

                foundVehicle.FillUpEnergy(kindOfFuel, amountToFill);
                Console.WriteLine("The vehicle fueled successfully.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                fuelVehicle();
            }
        }
예제 #8
0
 internal FuelProperties(float i_MaxFuelAmount, float i_CurrentFuelAmount, eKindOfFuel i_KindOfFuel)
     : base(i_CurrentFuelAmount, i_MaxFuelAmount)
 {
     m_KindOfFuel = i_KindOfFuel;
 }
예제 #9
0
 public Fuel(float i_CurrentAmountOfFuelInLiters, eKindOfFuel iRKindOfFuel, float iRMaximumAmountOfFuelPerLiter)
 {
     m_CurrentAmountOfFuelInLiters = i_CurrentAmountOfFuelInLiters;
     r_MaximumAmountOfFuelPerLiter = iRMaximumAmountOfFuelPerLiter;
     r_KindOfFuel = iRKindOfFuel;
 }
예제 #10
0
 public override abstract void FillUpEnergy(eKindOfFuel i_GivenFuelKind, float i_AmountToFill);
예제 #11
0
 public override void FillUpEnergy(eKindOfFuel i_GivenFuelKind, float i_AmountToFill)
 {
     throw new ArgumentException("You cannot fill up gas in an electric vehicle.");
 }