Exemplo n.º 1
0
        private 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();
        }
        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.Input = inputToParse;

            return(input);
        }
Exemplo n.º 3
0
        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();
            }
        }