Exemple #1
0
        //should allow user to see a list item based on a search for author or title
        private void SearchForItem() //will need a 'List<Item> libraryList' parameter
        {
            ValidatorClass session = new ValidatorClass();

            Console.WriteLine("Search by:\n     1. Author\n     2: Title\n     3. Return to Main Menu");
            int userInput = this.session.GetValidInput(this.session.GetUserInput("User Option: "), 1, 3);

            switch (userInput)
            {
            case 1:
                string userAuthor = session.GetUserInput("Enter the name of the author: ");
                session.SearchByAuthor(libraryList, userAuthor);
                UserContinue();
                break;

            case 2:
                string userTitle = session.GetUserInput("Enter the name of the title: ");
                session.SearchByTitle(libraryList, userTitle);
                UserContinue();
                break;

            case 3:
                PrintMainMenu();
                break;
            }
        }
Exemple #2
0
        private void PrintMainMenu()
        {
            Console.WriteLine();
            bool validChoice = true;

            while (validChoice)
            {
                Console.WriteLine("Welcome to the Libarary!");
                Console.WriteLine("1. Show Library Collection\n2. Search for Item\n3. Check out item\n4. Check in item\n5. Exit");
                int userSelection = session.GetValidInput(session.GetUserInput("Please choose from an option above: "), 1, 5);
                Console.Clear();
                validChoice = false;

                switch (userSelection)
                {
                case 1:
                    ListItems();
                    break;

                case 2:
                    SearchForItem();
                    break;

                case 3:
                    CheckOutItem();
                    break;

                case 4:
                    CheckInItem();
                    break;

                case 5:
                    ExitProgram();
                    break;

                default:
                    validChoice = true;
                    Console.WriteLine("Please make a valid selection (1 - 4).");
                    break;
                }
            }
        }
Exemple #3
0
        public int GetValidInput(string input, int min, int max)

        {
            ValidatorClass session = new ValidatorClass();

            try
            {
                int selection = int.Parse(input);
                if (selection >= min && selection <= max)

                {
                    return(selection);
                }
                else
                {
                    return(GetValidInput(session.GetUserInput($"Please enter an option between {min} - {max}: "), min, max));
                }
            }
            catch (FormatException)
            {
                return(GetValidInput(session.GetUserInput($"Please enter an option of {min} - {max}: "), min, max));
            }
        }