//Adds hotelName and rates dictionary hotelRatesDict. Overwrites rates if hotel already exists public bool AddHotel(string hotelName, int rating, int weekdaysRateForRegularCust, int weekendsRateForRegularCust, int weekdaysRateForRewardCust, int weekendsRateForRewardCust) { bool isHotelAdded = false; if (String.IsNullOrEmpty(hotelName)) { throw new HotelReservationException(HotelReservationException.ExceptionType.INVALID_HOTEL_NAME, "Invalid Hotel Name"); } List <int> rates = new List <int> { weekdaysRateForRegularCust, weekendsRateForRegularCust, weekdaysRateForRewardCust, weekendsRateForRewardCust }; //Removes hotel if already exists for overiding new rates if (hotelRatesDict.ContainsKey(hotelName)) { hotelRatesDict.Remove(hotelName); hotelRatings.Remove(hotelName); } //Adds rates to hotelRatesDict hotelRatesDict.Add(hotelName, rates); //Adds hotel rating to hotelRatings hotelRatings.Add(hotelName, rating); isHotelAdded = true; ColouredPrint.PrintInRed($"Added {hotelName}"); return(isHotelAdded); }
//private method to call FindBestHotel Method private static void GetBestHotel() { DateTime[] dates = AskStartAndEndDate(); CustomerType custType = AskCustomerType(); HotelReservation hotelReservationObj = new HotelReservation(custType, dates[0], dates[1]); string bestHotel = hotelReservationObj.FindBestHotel(); int cheapestRate = hotelReservationObj.FindCheapestTotalRate(); ColouredPrint.PrintInRed($"Best Hotel is {bestHotel} with Total rate {cheapestRate} and Rating {hotelReservationObj.FindBestHotelRating()}"); }
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(); }
//private method to call FindHighestRatedHotel method private static void GetHighestRatedHotel() { DateTime[] dates = AskStartAndEndDate(); CustomerType custType = AskCustomerType(); HotelReservation hotelReservationObj = new HotelReservation(custType, dates[0], dates[1]); string highestRatedHotel = hotelReservationObj.FindHighestRatedHotel(); int highestRatedHotelTotalRate = hotelReservationObj.FindHigestRatedHotelTotalRate(); int highestRatedHotelRating = hotelReservationObj.FindHighestRatedHotelRating(); ColouredPrint.PrintInRed($"Highest Rated hotel is {highestRatedHotel} with Total Fare {highestRatedHotelTotalRate} and Rating {highestRatedHotelRating}"); }
//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}"); }