Hotel
Represents a hotel that manages room bookings and availability.
Attributes:
| Name | Type | Description |
|---|---|---|
rooms |
List[Room]
|
List of Room objects representing the rooms in the hotel. |
Source code in hazbin_hotel/src/hotel.py
rooms: List[Room]
property
List[Room]: Gets the list of rooms in the hotel.
__init__(rooms)
Initializes the Hotel with a list of rooms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rooms
|
List[Room]
|
A list of Room objects available in the hotel. |
required |
add_room(room)
Adds a new room to the hotel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
room
|
Room
|
The room to add to the hotel. |
required |
check_room_type_availability(room_type)
Checks if there is a room of the specified type available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
room_type
|
RoomTypeEnum
|
The type of room to check availability for. |
required |
Returns:
| Type | Description |
|---|---|
Room | None
|
Room | None: An available room of the specified type. |
Raises:
| Type | Description |
|---|---|
RoomTypeNotAvailable
|
If no room of the specified type is available. |
Source code in hazbin_hotel/src/hotel.py
remove_room(room)
Removes a room from the hotel if it has no schedules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
room
|
Room
|
The room to be removed. |
required |
Raises:
| Type | Description |
|---|---|
RoomHasSchedule
|
If the room has scheduled bookings. |
Source code in hazbin_hotel/src/hotel.py
schedule_a_room(client_name, room_type, start_date, end_date)
Schedules a room for a client if available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_name
|
str
|
The name of the client making the booking. |
required |
room_type
|
RoomTypeEnum
|
The type of room requested. |
required |
start_date
|
datetime
|
The start date of the booking period. |
required |
end_date
|
datetime
|
The end date of the booking period. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the booking was successful. |
Raises:
| Type | Description |
|---|---|
RoomNotAvailable
|
If no room is available for the specified period. |