public static void Run()
        {
            string userInput = null;

            GarageLogic.Garage garage = new GarageLogic.Garage();

            while (!s_Exit)
            {
                showGarageMenu();
                userInput = Console.ReadLine();
                activeMethodAccordingToUserChoiseFromGarageMenu(ValidInputOptions.Parse(userInput), garage);
                exitIfUserDidNotChooseAnyOption();
            }

            writeHaveAGoodDayMsg();
        }
예제 #2
0
        public static ValidInputOptions Parse(string i_InputAsStr)
        {
            eValidInputOptions inputToParse = eValidInputOptions.One;

            if (i_InputAsStr == "2")
            {
                inputToParse = eValidInputOptions.Two;
            }
            else if (i_InputAsStr == "3")
            {
                inputToParse = eValidInputOptions.Three;
            }
            else if (i_InputAsStr == "4")
            {
                inputToParse = eValidInputOptions.Four;
            }
            else if (i_InputAsStr == "5")
            {
                inputToParse = eValidInputOptions.Five;
            }
            else if (i_InputAsStr == "6")
            {
                inputToParse = eValidInputOptions.Six;
            }
            else if (i_InputAsStr == "7")
            {
                inputToParse = eValidInputOptions.Seven;
            }
            else if (i_InputAsStr == "Q" || i_InputAsStr == "q")
            {
                inputToParse = eValidInputOptions.Exit;
            }
            else if (i_InputAsStr != "1")
            {
                throw new FormatException();
            }

            ValidInputOptions input = new ValidInputOptions();

            input.m_Input = inputToParse;

            return(input);
        }
        private static void activeMethodAccordingToUserChoiseFromGarageMenu(ValidInputOptions i_UserChoice, GarageLogic.Garage i_Garage)
        {
            switch (i_UserChoice.Input)
            {
            case eValidInputOptions.One:
                addNewVehicleToGarage(i_Garage);
                break;

            case eValidInputOptions.Two:
                showLicenseNumsOfVehiclesAccordingTheKey(i_Garage);
                break;

            case eValidInputOptions.Three:
                changeVehicleStatusAccordingThekey(i_Garage);
                break;

            case eValidInputOptions.Four:
                inflateWheelsToMaxPressure(i_Garage);
                break;

            case eValidInputOptions.Five:
                refeulFuelVehicle(i_Garage);
                break;

            case eValidInputOptions.Six:
                chargeElectricVehicle(i_Garage);
                break;

            case eValidInputOptions.Seven:
                showAllCurrentInformationOfVihecle(i_Garage);
                break;

            case eValidInputOptions.Exit:
                s_Exit = true;
                break;

            default:
                throw new ArgumentException();
            }
        }