コード例 #1
0
        private static void displayVehicleInformation()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            bool   isValidLicenseNumber   = false;
            string userInputLicenseNumber = string.Empty;

            while (!isValidLicenseNumber)
            {
                Console.WriteLine("Please enter a license number you would like to display it's information");
                userInputLicenseNumber = Console.ReadLine();

                if (!GarageFunctionalityManager.IsExistInGarage(userInputLicenseNumber))
                {
                    Console.WriteLine("The vehicle with the license number you entered is not in the garage.");
                }
                else
                {
                    isValidLicenseNumber = true;
                    GarageFunctionalityManager.DisplayVehicleInformation(userInputLicenseNumber);
                }
            }
        }
コード例 #2
0
        private static string getVehicleLicenseNumber()
        {
            string vehicleLicenseNumber = string.Empty;
            bool   isFoundInGarage      = false;

            Console.WriteLine("Please enter vehicles' license number");
            vehicleLicenseNumber = Console.ReadLine();
            isFoundInGarage      = GarageFunctionalityManager.IsExistInGarage(vehicleLicenseNumber);

            while (!isFoundInGarage)
            {
                Console.WriteLine("This vehicle doesn't exist in the garage. Please try another license number");
                vehicleLicenseNumber = Console.ReadLine();
                isFoundInGarage      = GarageFunctionalityManager.IsExistInGarage(vehicleLicenseNumber);
            }

            return(vehicleLicenseNumber);
        }
コード例 #3
0
        private static void chargeElectricVehicle()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            try
            {
                string licenseNumber    = getVehicleLicenseNumber();
                float  amountFuelToFill = getAmountOfEnergyToAdd();
                GarageFunctionalityManager.ChargeElectricVehicle(licenseNumber, amountFuelToFill);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
コード例 #4
0
        private static void inflateTiresToMaximum()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            string licenseNumber = getVehicleLicenseNumber();

            try
            {
                GarageFunctionalityManager.inflateTiresToMaximum(licenseNumber);
                Console.WriteLine("All the wheels of the vehicle have been filled.");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
コード例 #5
0
        private static void refuelFuelVehicle()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            try
            {
                string licenseNumber          = getVehicleLicenseNumber();
                FuelEngine.eFuelType fuelType = getFuelTypeFromUser();
                float amountFuelToFill        = getAmountOfEnergyToAdd();
                GarageFunctionalityManager.RefuelFuelVehicle(licenseNumber, fuelType, amountFuelToFill);
                Console.WriteLine("Refule is done.");
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
コード例 #6
0
        private static void changeCertainVehicleStatus()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            if (GarageFunctionalityManager.ListVehiclesInGarage.Count == 0)
            {
                Console.WriteLine("There are no vehicles in the garage. Choose another option");
            }
            else
            {
                bool   validInputFromUser    = false;
                string userInputString       = string.Empty;
                short  userInputNumberOption = 0;
                VehicleInGarage.eVehicleStatus vehicleRequestStatus = GarageLogic.VehicleInGarage.eVehicleStatus.None;
                string stringOutput = string.Format(
                    @"Please choose one of the options below:
1: In Repair (in progress) 
2: Is Repaired (fixed)
3: Is Paid ");
                string vehicleLicenseNumber = getVehicleLicenseNumber();

                while (!validInputFromUser)
                {
                    Console.WriteLine("Please select the status that you whould like to change to : ");
                    Console.WriteLine(stringOutput);
                    userInputString    = Console.ReadLine();
                    validInputFromUser = short.TryParse(userInputString, out userInputNumberOption);

                    if (!validInputFromUser || userInputNumberOption > 3 || userInputNumberOption < 1)
                    {
                        Console.WriteLine("Invalid input! Please enter a valid number from the options below.");
                        validInputFromUser = false;
                    }
                }

                switch (userInputNumberOption)
                {
                case 1:
                {
                    vehicleRequestStatus = VehicleInGarage.eVehicleStatus.InRepair;
                    break;
                }

                case 2:
                {
                    vehicleRequestStatus = VehicleInGarage.eVehicleStatus.IsRepaired;
                    break;
                }

                case 3:
                {
                    vehicleRequestStatus = VehicleInGarage.eVehicleStatus.IsPaid;
                    break;
                }
                }

                try
                {
                    GarageFunctionalityManager.ChangeCertainVehicleStatus(vehicleLicenseNumber, vehicleRequestStatus);
                }
                catch (ArgumentException exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }
        }
コード例 #7
0
        private static void showLicenseNumbers()
        {
            try
            {
                checkValidityOfUserOptionChoice();
            }
            catch (UnavailableOptionException exception)
            {
                throw exception;
            }

            bool          ValidInputFromUser     = false;
            string        userInputString        = string.Empty;
            short         userInputNumberOption  = 0;
            List <string> relevantLicenseNumbers = new List <string>();

            VehicleInGarage.eVehicleStatus vehicleStatus;

            string stringOutput = string.Format(
                @"Please choose one of the options below:
1: Show all vehicles
2: Show all vehicles that are in repair
3: Show all vehicles that have been repaired 
4: Show all vehicles that were paid");

            while (!ValidInputFromUser)
            {
                Console.WriteLine("Please select which vehicles would you like to see?");
                Console.WriteLine(stringOutput);
                userInputString    = Console.ReadLine();
                ValidInputFromUser = short.TryParse(userInputString, out userInputNumberOption);

                if (!ValidInputFromUser || userInputNumberOption > 4 || userInputNumberOption < 1)
                {
                    Console.WriteLine("Invalid Input! Please choose one of the valid options");
                    ValidInputFromUser = false;
                }
            }

            switch (userInputNumberOption)
            {
            case 1:
            {
                relevantLicenseNumbers = GarageFunctionalityManager.ShowAllVehiclesInGarage();
                break;
            }

            case 2:
            {
                vehicleStatus          = VehicleInGarage.eVehicleStatus.InRepair;
                relevantLicenseNumbers = GarageFunctionalityManager.ShowVehiclesByStatus(vehicleStatus);
                break;
            }

            case 3:
            {
                vehicleStatus          = VehicleInGarage.eVehicleStatus.IsRepaired;
                relevantLicenseNumbers = GarageFunctionalityManager.ShowVehiclesByStatus(vehicleStatus);
                break;
            }

            case 4:
            {
                vehicleStatus          = VehicleInGarage.eVehicleStatus.IsPaid;
                relevantLicenseNumbers = GarageFunctionalityManager.ShowVehiclesByStatus(vehicleStatus);
                break;
            }
            }

            if (relevantLicenseNumbers.Count == 0)
            {
                Console.WriteLine("There are no vehicles in the garage with the chosen status");
            }
            else
            {
                Console.WriteLine("The vehicles' license number with the chosen status are:");
                foreach (string currentlicenseNumber in relevantLicenseNumbers)
                {
                    Console.WriteLine(currentlicenseNumber);
                }
            }
        }
コード例 #8
0
        private static void addVehicleToGarage()
        {
            eVehicleTypes vehicleType = getVehicleTypeFromUser();

            GarageFunctionalityManager.AddVehicleToTheGarage(vehicleType);
        }