Пример #1
0
        private void fuelVehicle()
        {
            string      licensePlateNumber;
            float       additionalEnergy;
            eTypeOfFuel fuelType;

            licensePlateNumber = getLicenseInput();
            checkIfVehicleExists(licensePlateNumber);
            checkIfFuelledVehicle(licensePlateNumber);
            fuelType = getFuelTypeInput(licensePlateNumber);
            if (!m_GarageLogic.IsTypeOfFuelMatch(licensePlateNumber, fuelType))
            {
                throw new ArgumentException("Selected fuel type doesnt match");
            }

            additionalEnergy = getAdditionalEnergyInput();
            m_GarageLogic.AddEnergyToVehicle(licensePlateNumber, additionalEnergy, fuelType);
            Console.Clear();
            Console.WriteLine("Vehicle refuled");
            Thread.Sleep(k_afterExeptionTime);
        }
Пример #2
0
        private void refuelVehicle()
        {
            string licenseNumber = getNotEmptyStringFromUser(k_VehicleLicenseNumber);

            if (r_Garage.IsVehicleInTheGarage(licenseNumber))
            {
                if (r_Garage.CheckMotorType(licenseNumber, typeof(FuelMotor)))
                {
                    int   fuelTypeChoise       = getValidEnumOptionFromUser(k_VehicleFuelType, new Motor.eFuelType());
                    float amountOfFuelToRefuel = getValidFloatNumberFromUser(k_AmountOfFuel);
                    r_Garage.AddEnergyToVehicle(licenseNumber, amountOfFuelToRefuel, (Motor.eFuelType)fuelTypeChoise);
                    Console.WriteLine("{0}Successfully refuel the vehicle", Environment.NewLine);
                }
                else
                {
                    throw new ArgumentException("Error: You cant charge a fuel car");
                }
            }
            else
            {
                throw new Exception(k_VehicleNotExistErrorMessage);
            }
        }