Problem 4¶
Analyze the booking data of a hotel.
The data is given as: * The room number, * The beginning of the booking interval (as an integer, the day of year), * Tne end of the booking interval (as an integer, the day of year), * The price of the room per day, * The price discount (as a floating point number between 0 and 100).
All bookings start and end in the same year.
The program answers the following questions: * Which room was booked the most frequently? (as number of bookings) * Which room was booked the longest (as number of days) * Which room brought in the most revenue? * What is the total revenue of the hotel for the year?
Classes:
|
Represent an entry in the booking data. |
Functions:
|
Find the number of the most booked room in the |
|
Find the room booked for the longest accumulated time according to |
|
Find the room which brought in the most revenue according to |
|
Compute the total revenue of the hotel based on |
- class Entry(room_number: int, start: int, end: int, price_per_day: float, price_discount: float)[source]¶
Represent an entry in the booking data.
Methods:
__init__
(room_number, start, end, ...)Initialize with the given values.
duration
()Compute the duration of the stay.
__repr__
()Return repr(self).
- __init__(room_number: int, start: int, end: int, price_per_day: float, price_discount: float) None [source]¶
Initialize with the given values.
- Requires
not math.isnan(price_per_day) and price_per_day < 1e300
(Reasonable bounds to avoid NaN’s and inf’s)
not math.isnan(price_discount) and price_discount < 1e300
(Reasonable bounds to avoid NaN’s and inf’s)
0 <= price_discount <= 100
(The price discount is given as a percentage.)
price_per_day > 0
start <= end
(The start and end must occur in the same year)
1 <= end <= 366
(The end denotes the day of year.)
1 <= start <= 366
(The start denotes the day of year.)
room_number > 0
- most_booked_room(entries: List[Entry]) int [source]¶
Find the number of the most booked room in the
entries
.- Requires
len(entries) > 0
- Ensures
result in {entry.room_number for entry in entries}
- longest_booked_room(entries: Collection[Entry]) int [source]¶
Find the room booked for the longest accumulated time according to
entries
.- Requires
len(entries) > 0
- Ensures
result in {entry.room_number for entry in entries}