Skip to content

ksetoue/cheapest-hotel-2019

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hotel Reservation Problem

A hotel chain in Miami wants to offer a reservation service through the internet. Three hotels are part of the chain: Lakewood, Bridgewood and Ridgewood. Each one has different taxes for weekdays and weekends, including specific taxes for customers that are parte of a fidelity program. Additionally, each hotel has a classification score, that indicates service quality.

Here is the information for each hotel:

    Lakewood: {
        Name: "Lakewood",
        classification:     "3",
        taxWeekRegular:     "110",
        taxWeekRewards:     "80",
        taxWeekendRegular:  "90",
        taxWeekendRewards:  "80",
    }

    Bridgewood: {
        Name: "Bridgewood",
        classification:     "4",
        taxWeekRegular:     "160",
        taxWeekRewards:     "110",
        taxWeekendRegular:  "60",
        taxWeekendRewards:  "50",
    }

    Bridgewood: {
        Name: "Bridgewood",
        classification:     "5",
        taxWeekRegular:     "220",
        taxWeekRewards:     "100",
        taxWeekendRegular:  "150",
        taxWeekendRewards:  "40",
    }

This application

The main goal of this application is to return the name of the cheapest hotel for a customer, based on dates and customer type ("Regular" or "Rewards"). The output is the cheapest hotel, and in case of draw, the hotel with higher classification.

Architecture

The application is separated in two projects: ApplicationCore that controls the console application, and a classlib project called Booking.

  1. ApplicationCore
  • Responsible for reading the input file and calling methods that will return the cheapest hotels
  • Console application
  1. Booking
  • Library that holds the business logic from Hotels and reservations
  • ClassLib project, that can be used in other .net applications as a dll
  1. BookingTest
  • Test project for Booking
  • xUnit project

Booking

The components that define the booking lib are divided by domain, as described below:

Booking

|-- Hotels
    |-- HotelFactory
        |-- HotelFactory.cs --> returns a object list with default hotels configs
    |-- Hotel.cs --> class that defines a Hotel
    |-- HotelBooking.cs --> defines the relationship between a hotel and a booking request
|-- WeekDay
    |-- InvalidDayException.cs --> implements a modified throw for errors generated by invalid days entered
    |-- WeekDay.cs --> defines a enum that contains each day of the week

|-- Booking.cs --> defines methods to get cheapest hotel and booking related actions
|-- BookingService.cs --> defines methods that help build a booking request
|-- BookingRequest.cs --> defines a booking request format  
|-- PriceComparer.cs --> method to compare price and return if there is a draw between costs


ApplicationCore
|-- InputParser.cs --> methods to parse the input (is possible to change it to handle a http request)
|-- Program.cs --> Main class

Executing

To run this project, make sure you have the following requirements:

  • .net core 2.2

Before building and running the project, make sure to include your personalised data on input.txt file, located on ApplicationCore/assets/input.txt. Remember that each line of input.txt need to follow the pattern:

CustomerType : DDMMYY(day)

Example:

Regular: 16Mar2009(mon), 17Mar2009(tues), 18Mar2009(wed)
Regular: 20Mar2009(fri), 21Mar2009(sat), 22Mar2009(sun)
Rewards: 26Mar2009(thur), 27Mar2009(fri), 28Mar2009(sat)

To run the project, dowload the project and on the root directory run:

$ cd ApplicationCore
$ dotnet restore
$ dotnet build
$ dotnet run 

To run tests, on the root directory run:

$ cd BookingTest
$ dotnet restore
$ dotnet test

Future improvements

  • Run in docker - build the booking lib and application

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages