//Asks user for entry public static void ChooseOption() { Console.WriteLine("Enter 1 : Add Hotel\nEnter 2 : Show Cheapest Hotels\nEnter 3 : Book Best Hotel\nEnter 4 : Book Highest Rating Hotel\nEnter 5 : Exit"); Console.Write("Your Entry : "); int enteredKey = default(int); try { try { enteredKey = Convert.ToInt32(Console.ReadLine()); } catch { ColouredPrint.PrintInMagenta("Wrong key entered\nTry Again"); ChooseOption(); } switch (enteredKey) { case 1: CallingMethodsClass.CallAddHotel(); ChooseOption(); break; case 2: CallingMethodsClass.GetCheapestHotels(); ChooseOption(); break; case 3: CallingMethodsClass.GetBestHotel(); ChooseOption(); break; case 4: CallingMethodsClass.GetHighestRatedHotel(); ChooseOption(); break; case 5: break; default: ColouredPrint.PrintInMagenta("Wrong key entered\nTry Again"); ChooseOption(); break; } } //Catches exception if hotelName is Invalid catch (HotelReservationException e) { ColouredPrint.PrintInMagenta($"{e.Message}\nTry Again"); ChooseOption(); } }
static void Main(string[] args) { ColouredPrint.PrintInRed("Welcome to Hotel Reservation System", false, false); Console.WriteLine("==================================="); HotelDetails hotelDetailsTestObj = new HotelDetails(); hotelDetailsTestObj.AddHotel("Lakewood", 3, 110, 90, 80, 80); hotelDetailsTestObj.AddHotel("Bridgewood", 4, 150, 50, 110, 50); hotelDetailsTestObj.AddHotel("Ridgewood", 5, 220, 150, 100, 40); CallingMethodsClass.ChooseOption(); }