Пример #1
0
        public void refuelGasVehicle()
        {
            string licenseNumber = m_RefuelGasVehicle.GetLicenseNumberForRefuel();

            Gas.eGasType fuelType     = m_RefuelGasVehicle.GetFuelTypeForRefuel();
            float        amountOfFuel = m_RefuelGasVehicle.GetAmountOfLitersToFuel();

            try
            {
                m_Garage.RefuelGasVehicle(licenseNumber, fuelType, amountOfFuel);
                m_UserDisplay.ClearAndDisplayMessage(string.Format("Vehicle with license number: {0}, was refueled with gas type: {1}, and amount: {2} successfuly!", licenseNumber, fuelType, amountOfFuel));
                m_UserDisplay.PressAnyKeyToContinue();
            }
            catch (Exception exception)
            {
                m_UserDisplay.ClearAndDisplayMessage(exception.Message);

                if (exception is ValueOutOfRangeException)
                {
                    m_UserDisplay.DisplayMessage(Messages.k_PleaseTryAgainMessage);
                    m_UserDisplay.ReadLine();
                    refuelGasVehicle();
                }
                else
                {
                    m_UserDisplay.PressAnyKeyToContinue();
                }
            }
        }
Пример #2
0
        public void AddGas(string i_LicenseNumber, Gas.eGasType i_GasType, float i_AmountOfPowerToAdd)
        {
            Gas toRefill = r_VehiclesToFix[i_LicenseNumber].VehicleOfOwner.PowerSource as Gas;

            toRefill.AddPower(i_GasType, i_AmountOfPowerToAdd);
            r_VehiclesToFix[i_LicenseNumber].VehicleOfOwner.UpdatePercent();
        }
        public void RefuelGasVehicle(string i_LicenseNumber, Gas.eGasType i_GasType, float i_AmountOfGasToFill)
        {
            IsVehicleInGarageException(i_LicenseNumber);
            Vehicle vehicle = this.m_GarageVehicles[i_LicenseNumber];

            Gas.eGasType fuelType = i_GasType;

            if (!(vehicle.EnergySource is Gas))
            {
                throw new Exception("The given car is not working on gas!");
            }

            Gas gasEngine = (Gas)vehicle.EnergySource;

            gasEngine.FillGas(fuelType, i_AmountOfGasToFill);
            vehicle.SetEnergyPercentge();
        }