|
| 1 | +<h1 align="center">Design a Hotel Management System</h1> |
| 2 | +<h3 align="center">Let's design a hotel management system</h3> |
| 3 | + |
| 4 | +**We'll cover the following:** |
| 5 | + |
| 6 | +* [System Requirements](#system-requirements) |
| 7 | +* [Use Case Diagram](#use-case-diagram) |
| 8 | +* [Class Diagrams](#class-diagrams) |
| 9 | +* [Activity Diagram](#activity-diagram) |
| 10 | +* [Code](#code) |
| 11 | + |
| 12 | +A Hotel Management System is a software built to handle all online hotel activities easily and safely. This System will give the hotel management power and flexibility to manage the entire system from a single online portal. The system allows the manager to keep track of all the available rooms in the system as well as to book rooms and generate bills. |
| 13 | + |
| 14 | +<p align="center"> |
| 15 | + <img src="/media-files/hotel-management-system.png" alt="Hotel Management System"> |
| 16 | + <br /> |
| 17 | + Hotel Management System |
| 18 | +</p> |
| 19 | + |
| 20 | +### System Requirements |
| 21 | + |
| 22 | +We’ll focus on the following set of requirements while designing the Hotel Management System: |
| 23 | + |
| 24 | +1. The system should support the booking of different room types like standard, deluxe, family suite, etc. |
| 25 | +2. Guests should be able to search the room inventory and book any available room. |
| 26 | +3. The system should be able to retrieve information, such as who booked a particular room, or what rooms were booked by a specific customer. |
| 27 | +4. The system should allow customers to cancel their booking - and provide them with a full refund if the cancelation occurs before 24 hours of the check-in date. |
| 28 | +5. The system should be able to send notifications whenever the booking is nearing the check-in or check-out date. |
| 29 | +6. The system should maintain a room housekeeping log to keep track of all housekeeping tasks. |
| 30 | +7. Any customer should be able to add room services and food items. |
| 31 | +8. Customers can ask for different amenities. |
| 32 | +9. The customers should be able to pay their bills through credit card, check or cash. |
| 33 | + |
| 34 | +### Use Case Diagram |
| 35 | + |
| 36 | +Here are the main Actors in our system: |
| 37 | + |
| 38 | +* **Guest:** All guests can search the available rooms, as well as make a booking. |
| 39 | +* **Receptionist:** Mainly responsible for adding and modifying rooms, creating room bookings, check-in, and check-out customers. |
| 40 | +* **System:** Mainly responsible for sending notifications for room booking, cancellation, etc. |
| 41 | +* **Manager:** Mainly responsible for adding new workers. |
| 42 | +* **Housekeeper:** To add/modify housekeeping record of rooms. |
| 43 | +* **Server:** To add/modify room service record of rooms. |
| 44 | + |
| 45 | +Here are the top use cases of the Hotel Management System: |
| 46 | + |
| 47 | +* **Add/Remove/Edit room:** To add, remove, or modify a room in the system. |
| 48 | +* **Search room:** To search for rooms by type and availability. |
| 49 | +* **Register or cancel an account:** To add a new member or cancel the membership of an existing member. |
| 50 | +* **Book room:** To book a room. |
| 51 | +* **Check-in:** To let the guest check-in for their booking. |
| 52 | +* **Check-out:** To track the end of the booking and the return of the room keys. |
| 53 | +* **Add room charge:** To add a room service charge to the customer’s bill. |
| 54 | +* **Update housekeeping log:** To add or update the housekeeping entry of a room. |
| 55 | + |
| 56 | +Here is the use case diagram of our Hotel Management System: |
| 57 | + |
| 58 | +<p align="center"> |
| 59 | + <img src="/media-files/hms-use-case-diagram.svg" alt="Blackjack Use Case Diagram"> |
| 60 | + <br /> |
| 61 | + Use Case Diagram for Hotel Management System |
| 62 | +</p> |
| 63 | + |
| 64 | +### Class Diagram |
| 65 | + |
| 66 | +Here are the main classes of our Hotel Management System: |
| 67 | + |
| 68 | +* **Hotel and HotelLocation:** Our system will support multiple locations of a hotel. |
| 69 | +* **Room:** The basic building block of the system. Every room will be uniquely identified by the room number. Each Room will have attributes like Room Style, Booking Price, etc. |
| 70 | +* **Account:** We will have different types of accounts in the system: one will be a guest to search and book rooms, another will be a receptionist. Housekeeping will keep track of the housekeeping records of a room, and a Server will handle room service. |
| 71 | +* **RoomBooking:** This class will be responsible for managing bookings for a room. |
| 72 | +* **Notification:** Will take care of sending notifications to guests. |
| 73 | +* **RoomHouseKeeping:** To keep track of all housekeeping records for rooms. |
| 74 | +* **RoomCharge:** Encapsulates the details about different types of room services that guests have requested. |
| 75 | +* **Invoice:** Contains different invoice-items for every charge against the room. |
| 76 | +* **RoomKey:** Each room can be assigned an electronic key card. Keys will have a barcode and will be uniquely identified by a key-ID. |
| 77 | + |
| 78 | +<p align="center"> |
| 79 | + <img src="/media-files/hms-class-diagram.png" alt="Hotel Management System Class Diagram"> |
| 80 | + <br /> |
| 81 | + Class Diagram for Hotel Management System |
| 82 | +</p> |
| 83 | + |
| 84 | +<p align="center"> |
| 85 | + <img src="/media-files/hms-uml.svg" alt="Hotel Management System UML"> |
| 86 | + <br /> |
| 87 | + UML for Hotel Management System |
| 88 | +</p> |
| 89 | + |
| 90 | +### Activity Diagrams |
| 91 | + |
| 92 | +**Make a room booking:** Any guest or receptionist can perform this activity. Here are the set of steps to book a room: |
| 93 | + |
| 94 | +<p align="center"> |
| 95 | + <img src="/media-files/hms-room-booking-activity-diagram.svg" alt="Hotel Management System Room Booking"> |
| 96 | + <br /> |
| 97 | + Activity Diagram for Hotel Management System Room Booking |
| 98 | +</p> |
| 99 | + |
| 100 | +**Check in:** Guest will check in for their booking. The Receptionist can also perform this activity. Here are the steps: |
| 101 | + |
| 102 | +<p align="center"> |
| 103 | + <img src="/media-files/hms-check-in-activity-diagram.svg" alt="Hotel Management System Check in"> |
| 104 | + <br /> |
| 105 | + Activity Diagram for Hotel Management System Check in |
| 106 | +</p> |
| 107 | + |
| 108 | +**Cancel a booking:** Guest can cancel their booking. Receptionist can perform this activity. Here are the different steps of this activity: |
| 109 | + |
| 110 | +<p align="center"> |
| 111 | + <img src="/media-files/hms-cancel-booking-activity-diagram.svg" alt="Hotel Management System Cancel Booking"> |
| 112 | + <br /> |
| 113 | + Activity Diagram for Hotel Management System Cancel Booking |
| 114 | +</p> |
| 115 | + |
| 116 | +### Code |
| 117 | + |
| 118 | +Here is the high-level definition for the classes described above. |
| 119 | + |
| 120 | +**Enums, data types, and constants:** Here are the required enums, data types, and constants: |
| 121 | + |
| 122 | +```python |
| 123 | +from enum import Enum |
| 124 | + |
| 125 | + |
| 126 | +class RoomStyle(Enum): |
| 127 | + STANDARD, DELUXE, FAMILY_SUITE, BUSINESS_SUITE = 1, 2, 3, 4 |
| 128 | + |
| 129 | + |
| 130 | +class RoomStatus(Enum): |
| 131 | + AVAILABLE, RESERVED, OCCUPIED, NOT_AVAILABLE, BEING_SERVICED, OTHER = 1, 2, 3, 4, 5, 6 |
| 132 | + |
| 133 | + |
| 134 | +class BookingStatus(Enum): |
| 135 | + REQUESTED, PENDING, CONFIRMED, CHECKED_IN, CHECKED_OUT, CANCELLED, ABANDONED = 1, 2, 3, 4, 5, 6, 7 |
| 136 | + |
| 137 | + |
| 138 | +class AccountStatus(Enum): |
| 139 | + ACTIVE, CLOSED, CANCELED, BLACKLISTED, BLOCKED = 1, 2, 3, 4, 5 |
| 140 | + |
| 141 | + |
| 142 | +class AccountType(Enum): |
| 143 | + MEMBER, GUEST, MANAGER, RECEPTIONIST = 1, 2, 3, 4 |
| 144 | + |
| 145 | + |
| 146 | +class PaymentStatus(Enum): |
| 147 | + UNPAID, PENDING, COMPLETED, FILLED, DECLINED, CANCELLED, ABANDONED, SETTLING, SETTLED, REFUNDED = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 |
| 148 | + |
| 149 | + |
| 150 | +class Address: |
| 151 | + def __init__(self, street, city, state, zip_code, country): |
| 152 | + self.__street_address = street |
| 153 | + self.__city = city |
| 154 | + self.__state = state |
| 155 | + self.__zip_code = zip_code |
| 156 | + self.__country = country |
| 157 | + |
| 158 | + |
| 159 | +``` |
| 160 | + |
| 161 | +**Account, Person, Guest, Receptionist, and Server:** These classes represent the different people that interact with our system: |
| 162 | + |
| 163 | +```python |
| 164 | +from abc import ABC |
| 165 | +from .constants import * |
| 166 | + |
| 167 | + |
| 168 | +# For simplicity, we are not defining getter and setter functions. The reader can |
| 169 | +# assume that all class attributes are private and accessed through their respective |
| 170 | +# public getter methods and modified only through their public methods function. |
| 171 | + |
| 172 | +class Account: |
| 173 | + def __init__(self, id, password, status=AccountStatus.Active): |
| 174 | + self.__id = id |
| 175 | + self.__password = password |
| 176 | + self.__status = status |
| 177 | + |
| 178 | + def reset_password(self): |
| 179 | + None |
| 180 | + |
| 181 | + |
| 182 | +# from abc import ABC, abstractmethod |
| 183 | +class Person(ABC): |
| 184 | + def __init__(self, name, address, email, phone, account): |
| 185 | + self.__name = name |
| 186 | + self.__address = address |
| 187 | + self.__email = email |
| 188 | + self.__phone = phone |
| 189 | + self.__account = account |
| 190 | + |
| 191 | + |
| 192 | +class Guest(Person): |
| 193 | + def __init__(self): |
| 194 | + self.__total_rooms_checked_in = 0 |
| 195 | + |
| 196 | + def get_bookings(self): |
| 197 | + None |
| 198 | + |
| 199 | + |
| 200 | +class Receptionist(Person): |
| 201 | + def search_member(self, name): |
| 202 | + None |
| 203 | + |
| 204 | + def create_booking(self): |
| 205 | + None |
| 206 | + |
| 207 | + |
| 208 | +class Server(Person): |
| 209 | + def add_room_charge(self, room, room_charge): |
| 210 | + None |
| 211 | + |
| 212 | +``` |
| 213 | + |
| 214 | +**Hotel and HotelLocation:** These classes represent the top-level classes of the system: |
| 215 | + |
| 216 | +```python |
| 217 | +class HotelLocation: |
| 218 | + def __init__(self, name, address): |
| 219 | + self.__name = name |
| 220 | + self.__location = address |
| 221 | + |
| 222 | + def get_rooms(self): |
| 223 | + None |
| 224 | + |
| 225 | + |
| 226 | +class Hotel: |
| 227 | + def __init__(self, name): |
| 228 | + self.__name = name |
| 229 | + self.__locations = [] |
| 230 | + |
| 231 | + def add_location(self, location): |
| 232 | + None |
| 233 | + |
| 234 | +``` |
| 235 | + |
| 236 | +**Room, RoomKey, and RoomHouseKeeping:** To encapsulate a room, room key, and housekeeping: |
| 237 | + |
| 238 | +```python |
| 239 | +from datetime import datetime |
| 240 | +from abc import ABC |
| 241 | + |
| 242 | + |
| 243 | +class Search(ABC): |
| 244 | + def search(self, style, start_date, duration): |
| 245 | + None |
| 246 | + |
| 247 | + |
| 248 | +class Room(Search): |
| 249 | + def __init__(self, room_number, room_style, status, price, is_smoking): |
| 250 | + self.__room_number = room_number |
| 251 | + self.__style = room_style |
| 252 | + self.__status = status |
| 253 | + self.__booking_price = price |
| 254 | + self.__is_smoking = is_smoking |
| 255 | + |
| 256 | + self.__keys = [] |
| 257 | + self.__house_keeping_log = [] |
| 258 | + |
| 259 | + def is_room_available(self): |
| 260 | + None |
| 261 | + |
| 262 | + def check_in(self): |
| 263 | + None |
| 264 | + |
| 265 | + def check_out(self): |
| 266 | + None |
| 267 | + |
| 268 | + def search(self, style, start_date, duration): |
| 269 | + None |
| 270 | + |
| 271 | + |
| 272 | +# return all rooms with the given style and availability |
| 273 | + |
| 274 | + |
| 275 | +class RoomKey: |
| 276 | + def __init__(self, key_id, barcode, is_active, is_master): |
| 277 | + self.__key_id = key_id |
| 278 | + self.__barcode = barcode |
| 279 | + self.__issued_at = datetime.date.today() |
| 280 | + self.__active = is_active |
| 281 | + self.__is_master = is_master |
| 282 | + |
| 283 | + def assign_room(self, room): |
| 284 | + None |
| 285 | + |
| 286 | + def is_active(self): |
| 287 | + None |
| 288 | + |
| 289 | + |
| 290 | +class RoomHouseKeeping: |
| 291 | + def __init__(self, description, duration, house_keeper): |
| 292 | + self.__description = description |
| 293 | + self.__start_datetime = datetime.date.today() |
| 294 | + self.__duration = duration |
| 295 | + self.__house_keeper = house_keeper |
| 296 | + |
| 297 | + def add_house_keeping(self, room): |
| 298 | + None |
| 299 | + |
| 300 | +``` |
| 301 | + |
| 302 | +**RoomBooking and RoomCharge:** To encapsulate a booking and different charges against a booking: |
| 303 | + |
| 304 | +```python |
| 305 | +from datetime import datetime |
| 306 | +from abc import ABC |
| 307 | + |
| 308 | + |
| 309 | +class RoomBooking: |
| 310 | + def __init__(self, reservation_number, start_date, duration_in_days, booking_status): |
| 311 | + self.__reservation_number = reservation_number |
| 312 | + self.__start_date = start_date |
| 313 | + self.__duration_in_days = duration_in_days |
| 314 | + self.__status = booking_status |
| 315 | + self.__checkin = None |
| 316 | + self.__checkout = None |
| 317 | + |
| 318 | + self.__guest_id = 0 |
| 319 | + self.__room = None |
| 320 | + self.__invoice = None |
| 321 | + self.__notifications = [] |
| 322 | + |
| 323 | + def fetch_details(self, reservation_number): |
| 324 | + None |
| 325 | + |
| 326 | + |
| 327 | +# from abc import ABC, abstractmethod |
| 328 | +class RoomCharge(ABC): |
| 329 | + def __init__(self): |
| 330 | + self.__issue_at = datetime.date.today() |
| 331 | + |
| 332 | + def add_invoice_item(self, invoice): |
| 333 | + None |
| 334 | + |
| 335 | + |
| 336 | +class Amenity(RoomCharge): |
| 337 | + def __init__(self, name, description): |
| 338 | + self.__name = name |
| 339 | + self.__description = description |
| 340 | + |
| 341 | + |
| 342 | +class RoomService(RoomCharge): |
| 343 | + def __init__(self, is_chargeable, request_time): |
| 344 | + self.__is_chargeable = is_chargeable |
| 345 | + self.__request_time = request_time |
| 346 | + |
| 347 | + |
| 348 | +class KitchenService(RoomCharge): |
| 349 | + def __init__(self, description): |
| 350 | + self.__description = description |
| 351 | + |
| 352 | +``` |
| 353 | + |
| 354 | + |
| 355 | + |
0 commit comments