Beispiel #1
0
        private void showFilteredId()
        {
            int           userChoice, enumLength;
            StringBuilder stringOfIdToPrint;
            bool          isInputValid = false;

            enumLength = Enum.GetNames(typeof(StoredVehicle.eVehicleState)).Length;
            while (!isInputValid)
            {
                try
                {
                    OutputManager.ShowFilterByVehicleStateScreen();
                    userChoice = InputManager.GetInputAndConvertToInt();
                    isInRange(userChoice, 1, enumLength + 1);
                    stringOfIdToPrint = getFilteredVehicleId(userChoice);
                    OutputManager.ShowMessage(stringOfIdToPrint.ToString());
                    pressToContinue();
                    isInputValid = true;
                }
                catch (FormatException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Invalid input. {0}", ex.Message));
                    pressToContinue();
                }
                catch (ValueOutOfRangeException ex)
                {
                    OutputManager.ShowErrorMessage(string.Format("Invalid input. {0}", ex.Message));
                    pressToContinue();
                }
            }
        }