private void MakeReservations() { GetAllCampgrounds(); ReservationCLI r = new ReservationCLI(parkID); r.Display(); }
/// <summary> /// Takes in a user input to chose a park and reservation time /// </summary> /// <returns>Reservation</returns> private ReservationCLI GetUserSelection() { Campground campground = new Campground(); Console.WriteLine(); Console.WriteLine("Which campground (enter 0 to cancel)"); string userSelectionString = Console.ReadLine(); // While the userSelectionString can't be parsed as an integer, // or the userSelectionString refers to an element that does not exist, // or the userSelectionString is less than 1, // prompt for input while (int.TryParse(userSelectionString, out int discard) == false || int.Parse(userSelectionString) > this.campground.Count || int.Parse(userSelectionString) < 0) { Console.WriteLine("Sorry, that's not a valid selection."); Console.WriteLine("Please make another selection."); userSelectionString = Console.ReadLine(); } if (int.Parse(userSelectionString) == 0) { return(new ReservationCLI(campground, false)); } int userSelection = int.Parse(userSelectionString); campground = this.campground[userSelection - 1]; Console.WriteLine(); Console.WriteLine($"{campground.Name} selected!"); Console.WriteLine(); ReservationCLI reservationCLI = new ReservationCLI(campground, true); return(reservationCLI); }