public void RunCLI()
        {
            // Prints Opening menu sequence, calls method to list the available parks and prompts user to enter a number to select a park //
            // customerSelection subtracts 1 from user input to set it equal to the selected park's index # in the list //
            PrintHeader();
            Console.WriteLine();
            PrintParksMenu();
            Console.WriteLine();
            List <Park> listOfAllParks = ListAllParks();

            Console.WriteLine();
            string input = CLIHelper.GetString("Enter a number: ").ToUpper();

            if (input == "Q")
            {
                Console.WriteLine("Exiting Program, please wait!");
                return;
            }
            else if (!int.TryParse(input, out int x))
            {
                Console.WriteLine("Invalid input, retry!");
                Thread.Sleep(milliseconds);
                Console.Clear();
                RunCLI();
            }
            else if (int.Parse(input) > listOfAllParks.Count)
            {
                Console.WriteLine("That park does not exist, retry!");
                Thread.Sleep(milliseconds);
                Console.Clear();
                RunCLI();
            }
            else
            {
                int inputAsAnInt = int.Parse(input);
                customerSelection = inputAsAnInt - 1;
                Console.Clear();
                // calls the method DisplayParkInfo to display the information for the selected park //
                List <Park> customerParkSelection = DisplayParkInfo();
                Console.WriteLine();
                // stores the selected park as a constructor and carries it to the campgrounds submenu //
                CampgroundsInterface campgroundsSubmenu = new CampgroundsInterface(customerParkSelection[customerSelection]);
                campgroundsSubmenu.Display();
            }
        }
Ejemplo n.º 2
0
        public void Display()

        {
            // prompts user to view available campgrounds or return to previous screen //
            PrintMenu();
            parkInfoSelection = CLIHelper.GetInteger("Select a command: ");
            Console.WriteLine();
            if (parkInfoSelection != 1 && parkInfoSelection != 2 && parkInfoSelection != 3)
            {
                Console.WriteLine("Invalid Input, returning to main menu!");
                Thread.Sleep(milliseconds);
                Console.Clear();
                ParksInterface mainmenu = new ParksInterface();
                mainmenu.RunCLI();
            }
            // user selected to view available campgrounds //
            if (parkInfoSelection == 1)
            {
                // Clears screen and calls method that shows menu of campgrounds at the selected park //
                // prompts user to search for available reservations or return to previous menu //
                Console.Clear();
                ViewCampgrounds();
                Console.WriteLine();
                PrintMenu2();

                // Checks if user entered 1 or 2, if not, sends back to previous menu display //
                if (parkCampgroundSelection != 1 && parkCampgroundSelection != 2)
                {
                    Console.WriteLine("Invalid Input, Campground Menu!");
                    Thread.Sleep(milliseconds);
                    Console.Clear();
                    Display();
                }

                // user selected to search for available reservations //
                if (parkCampgroundSelection == 1)
                {
                    // clears screen and displays a list of campgrounds for selected park //
                    // saves selected campground and carries it to reservation subMenu //
                    Console.Clear();
                    List <Campground>    campgroundsForCurrentPark = ViewCampgrounds();
                    ReservationInterface reservationSubmenu        = new ReservationInterface(campgroundsForCurrentPark);
                    reservationSubmenu.Display();
                }

                // user opted to return to previous menu //
                // the constructor keeps the selectedPark //
                // the method ensures the park info is redisplayed for the user //
                else if (parkCampgroundSelection == 2)
                {
                    Console.Clear();
                    DisplayParkInfo();
                    CampgroundsInterface reuturnToPreviousMenu = new CampgroundsInterface(selectedPark);
                    reuturnToPreviousMenu.Display();
                }
            }

            // THIS IS ONE OF THE BONUS SELECTIONS FOR PARKWIDE RESOS (CURRENTLY NOT IMPLEMENTED) //
            else if (parkInfoSelection == 2)
            {
                Console.WriteLine("This option is currently not available, returning to mainmenu!");
                Thread.Sleep(milliseconds);
                Console.Clear();
                ParksInterface mainmenu = new ParksInterface();
                mainmenu.RunCLI();
            }

            // user opted to return to the main menu //
            else if (parkInfoSelection == 3)
            {
                Console.Clear();
                ParksInterface mainmenu = new ParksInterface();
                mainmenu.RunCLI();
            }
        }