Exemple #1
0
        /// <summary>
        /// Displays information about the park and menu for further options.
        /// </summary>
        /// <param name="park"></param>
        private void ParkMenu(Park park)
        {
            const ConsoleKey VIEW_CAMP_KEY            = ConsoleKey.D1;
            const ConsoleKey SEARCH_RESERVATION_KEY   = ConsoleKey.D2;
            const ConsoleKey UPCOMING_RESERVATION_KEY = ConsoleKey.D3;
            const ConsoleKey RETURN_KEY = ConsoleKey.Q;

            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                PrintColoredMessage($"{park.Name} National Park Location: {park.Location}", ConsoleColor.Yellow);
                Console.WriteLine($"Established: {park.EstablishDate.ToShortDateString()}");
                Console.WriteLine($"Area: {park.Area}");
                Console.WriteLine($"Annual Visitors: {park.AnnualVisitors}");
                Console.WriteLine();
                Console.WriteLine(park.Description);
                Console.WriteLine();
                Console.WriteLine("Select a Command: ");
                Console.WriteLine($"{VIEW_CAMP_KEY.ToString().Substring(1)}) View Campgrounds");
                Console.WriteLine($"{SEARCH_RESERVATION_KEY.ToString().Substring(1)}) Search for Reservation");
                Console.WriteLine($"{UPCOMING_RESERVATION_KEY.ToString().Substring(1)}) See upcoming reservations");
                Console.WriteLine($"{RETURN_KEY}) Return to Previous Screen");

                var userSelection = Console.ReadKey(true).Key;

                if (userSelection == VIEW_CAMP_KEY)
                {
                    ViewCampground(park);
                }
                else if (userSelection == SEARCH_RESERVATION_KEY)
                {
                    ParkWideSearchAskInputsMenu(park);
                }
                else if (userSelection == UPCOMING_RESERVATION_KEY)
                {
                    ShowUpcomingReservationsMenu(park);
                }
                else if (userSelection == RETURN_KEY)
                {
                    exit = true;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// View all the campgrounds for that park.
        /// </summary>
        /// <param name="park"></param>
        private void ViewCampground(Park park)
        {
            const ConsoleKey SEARCH_RESERVATION_KEY = ConsoleKey.D1;
            const ConsoleKey RETURN_KEY             = ConsoleKey.D2;
            var camps = Npsd.GetCampgrounds(park);

            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                Console.WriteLine("   Name".PadRight(39) + "Open".PadRight(11) + "Close".PadRight(11) + "Daily Fee");

                foreach (var camp in camps)
                {
                    Console.WriteLine($"{camp.Key}) {camp.Value.Name.PadRight(35)} {camp.Value.OpeningMonth.PadRight(10)}" +
                                      $" {camp.Value.ClosingMonth.PadRight(10)} {camp.Value.DailyFee:c}");
                }

                Console.WriteLine();
                Console.WriteLine("Select a Command");
                Console.WriteLine($"{SEARCH_RESERVATION_KEY.ToString().Substring(1)}) Search for Available Reservation");
                Console.WriteLine($"{RETURN_KEY.ToString().Substring(1)}) Return to Previous Screen");

                var userSelection = Console.ReadKey(true).Key;

                if (userSelection == SEARCH_RESERVATION_KEY)
                {
                    Console.WriteLine();

                    int campSelected = ParseUserInputRequired("Which campground (enter 0 to cancel)? ");

                    if (campSelected != 0 && camps.ContainsKey(campSelected))
                    {
                        DateTime arrivalDate   = ParseUserDateRequired("What is the arrival date (MM/DD/YYYY)? ");
                        DateTime departureDate = ParseUserDateRequired("What is the departure date (MM/DD/YYYY)? ");

                        if (arrivalDate > DateTime.Now && departureDate > arrivalDate)
                        {
                            if (camps[campSelected].CampOpenInDateRange(arrivalDate, departureDate))
                            {
                                int  occupancy  = ParseUserInputRequired("Number of occupants? ");
                                bool accessible = ParseUserBoolRequired("Accessiblity requirements (true, false): ");
                                int  rvLength   = ParseUserInputRequired("RV Length requirements (0 if no RV): ");
                                bool utility    = ParseUserBoolRequired("Utility hookup Required (true, false)? ");

                                SearchCampgroundForAvailableReservationMenu(camps[campSelected], occupancy, accessible, rvLength, utility, arrivalDate, departureDate);
                            }
                            else
                            {
                                PrintMessageToScreen("Sorry the campground is closed in that date range. Please try a different date range.");
                            }
                        }
                        else
                        {
                            PrintMessageToScreen("Invalid date entry, please try again...");
                        }
                    }
                    else if (campSelected != 0 && !camps.ContainsKey(campSelected))
                    {
                        PrintMessageToScreen("Invalid camp selection, please try again...");
                    }
                }
                else if (userSelection == RETURN_KEY)
                {
                    exit = true;
                }
            }
        }