예제 #1
0
        public void ChargeEnergySource(ChargingVehicleDetails i_ChargingVehicleDetails)
        {
            try
            {
                r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle.EnergySource.ChargeEnergySource(i_ChargingVehicleDetails);
                r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle.UpdateEnergyPercent();
            }
            catch (ValueOutOfRangeException valueOutOfRangeException)
            {
                float fixedQuantityToAdd;
                if (r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle.EnergySource
                    .QuantityOfEnergyLeft + i_ChargingVehicleDetails.QuantityOfEnergyToAdd > 0)
                {
                    fixedQuantityToAdd =
                        r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle.EnergySource
                        .MaxOfEnergyCanContain - r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber]
                        .Vehicle.EnergySource.QuantityOfEnergyLeft;
                }
                else
                {
                    fixedQuantityToAdd = r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle
                                         .EnergySource.QuantityOfEnergyLeft * -1;
                }

                ChargingVehicleDetails fixedForm = new ChargingVehicleDetails(i_ChargingVehicleDetails.LicenceNumber, fixedQuantityToAdd, i_ChargingVehicleDetails.TypeOfEnergySource, i_ChargingVehicleDetails.FuelType);
                r_DictionaryOfAllPatient[i_ChargingVehicleDetails.LicenceNumber].Vehicle.EnergySource.ChargeEnergySource(i_ChargingVehicleDetails);

                throw valueOutOfRangeException;
            }
        }
예제 #2
0
        public override void ChargeEnergySource(ChargingVehicleDetails i_ChargingDetails)
        {
            checkEnergySourceType(i_ChargingDetails.TypeOfEnergySource);
            checkForDeviationInTank(i_ChargingDetails.QuantityOfEnergyToAdd);

            this.QuantityOfEnergyLeft += i_ChargingDetails.QuantityOfEnergyToAdd;
        }
예제 #3
0
        public override void ChargeEnergySource(ChargingVehicleDetails i_ChargingDetails)
        {
            // catch exception
            checkEnergySourceType(i_ChargingDetails.TypeOfEnergySource);
            checkForAvailableTypeOfFuel(i_ChargingDetails.FuelType.Value);
            checkForDeviationInTank(i_ChargingDetails.QuantityOfEnergyToAdd);

            this.QuantityOfEnergyLeft += i_ChargingDetails.QuantityOfEnergyToAdd;
        }