static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Hotels in Miami!");                                        //Welcome to Hotel Reservation System

            inputFromUserserInput();                                                                 //Input Date Range and Customer Type from User

            HotelReservation hotelReservation = new HotelReservation();

            AddSampleHotels(hotelReservation);                                                        //Add Hotel Name to HotelList

            //Find the cheapest hotel in the date Range
            var cheapestHotels = hotelReservation.FindCheapestHotels(startDate, endDate, customerType);
            var cost           = hotelReservation.CalculateTotalCost(cheapestHotels[0], startDate, endDate, customerType);

            //Print the name and cost
            Console.WriteLine("Hotel: {0}, Total Cost : {1}", cheapestHotels[0].name, cost);                        //Print the Name of first Element if same

            //Best Rated Hotel in the date Range
            var bestRatedHotel = hotelReservation.FindBestRatedHotel(startDate, endDate);

            Console.WriteLine("Hotel: {0} Rating: {1}", bestRatedHotel[0].name, bestRatedHotel[0].rating);

            //Best and cheapest hotels

            var bestandcheapesthotel = hotelReservation.FindCheapestBestRatedHotel(endDate, endDate, customerType);
            var totalcost            = hotelReservation.CalculateTotalCost(cheapestHotels[0], startDate, endDate, customerType);

            Console.WriteLine("Hotel: {0} Rating {1} Cost ", bestandcheapesthotel[0].name, bestandcheapesthotel[0].rating, cost);
        }
        //Private method to call FindCheapestHotels method
        private static void GetCheapestHotels()
        {
            DateTime[]       dates               = AskStartAndEndDate();
            CustomerType     custType            = AskCustomerType();
            HotelReservation hotelReservationObj = new HotelReservation(custType, dates[0], dates[1]);
            List <string>    cheapestHotels      = hotelReservationObj.FindCheapestHotels();
            int cheapestRate = hotelReservationObj.FindCheapestTotalRate();

            ColouredPrint.PrintInRed("Cheapest hotels is/are : ", false, false);
            foreach (string hotel in cheapestHotels)
            {
                ColouredPrint.PrintInRed($"{hotel}");
            }
            ColouredPrint.PrintInRed($"Cheapest Rate is {cheapestRate}");
        }
Пример #3
0
 //UC2 - UC4           
 public static void FindCheapest(HotelReservation hotelReservation, CustomerType ct)
 {
     Console.WriteLine("Cheapest Hotel");
     Console.Write("Enter the date range : ");
     var input = Console.ReadLine();
     string[] dates = input.Split(',');
     try
     {
         var startDate = Convert.ToDateTime(dates[0]);
         var endDate = Convert.ToDateTime(dates[1]);
         var cheapestHotel = hotelReservation.FindCheapestHotels(startDate, endDate, ct);
         foreach (Hotel h in cheapestHotel)
         {
             var cost = hotelReservation.CalculateTotalCost(h, startDate, endDate, ct);
             Console.WriteLine("Hotel : {0}, Total Cost : {1}", h.name, cost);
         }
     }
     catch
     {
         Console.Write("Enter the correct date range \n");
         FindCheapest(hotelReservation, ct);
     }
 }