示例#1
0
        static void Main(string[] args)
        {
            HotelReservation hotelReservation = new HotelReservation();

            Console.WriteLine("Welcome to Hotel Reservation Program");
            //instatiating hotel reservations
            List <DayOfWeek> datesList;

            //getting input from user
            string[] datesArray = InputCustomerTypeAndDate();

            //adding data into hotel list in hotel reservations using customer type
            AddingHotelDataAccToCustomerType(hotelReservation, datesArray);

            //adding dates in list and converting them to days of week
            //if date input is not in correct form, then custom exception thrown by method is catched.
            try
            {
                datesList = hotelReservation.AddingDatesInList(datesArray);
            }
            catch (HotelReservationCustomExceptions ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            //iterating loop until user wants to find best hotels
            while (true)
            {
                Console.WriteLine("Please Enter 1 to find cheapest hotel\nPlease Enter 2 to find hotel with best ratings");
                //reading input to choose between cheap hotel or best rated hotel
                int option = Convert.ToInt32(Console.ReadLine());
                switch (option)
                {
                case 1:
                    //calling the method for getting cheapest hotel for given dates
                    hotelReservation.CheapestHotelForGivenDates(datesList);
                    break;

                case 2:
                    //calling method to calculate best rated hotel
                    hotelReservation.FindingHotelsWithBestRatings(datesList);
                    break;

                default:
                    Console.WriteLine("Please enter the correct input");
                    break;
                }
                Console.WriteLine("Do you want to find out again,press y to check again");
                string check = Console.ReadLine();
                if (!(check.ToLower().Equals("y")))
                {
                    break;
                }
            }
        }