problemmediumooddesign-a-hotel-management-systemdesign a hotel management systemdesignahotelmanagementsystemobject-oriented-design-for-a-hotel-management-systemobject oriented design for a hotel management systemobjectorienteddesignforahotelmanagementsystem

OOD - Hotel Management System

MediumUpdated: Jan 1, 2026

1. Problem Statement

Modern hotels face complex operational challenges in managing guest reservations, room inventory, housekeeping schedules, billing systems, and customer service requests across multiple departments. A comprehensive Hotel Management System must coordinate these diverse operations while providing real-time visibility into room availability, automated pricing strategies, and seamless integration of ancillary services such as dining, spa treatments, and event bookings. The system needs to handle concurrent bookings, prevent double-reservations, track room maintenance status, manage staff assignments, and generate detailed financial reports while ensuring exceptional guest experiences through personalized service delivery.

The operational complexity extends beyond simple room bookings to encompass revenue management through dynamic pricing based on occupancy rates and seasonal demand, loyalty program integration, multi-property support for hotel chains, and compliance with local regulations regarding guest registration and tax collection. The system must support various stakeholder interactions: guests making reservations and checking availability, front desk staff processing check-ins and check-outs, housekeeping teams updating room status, maintenance crews reporting and resolving issues, restaurant staff coordinating meal services, and managers analyzing performance metrics and making strategic decisions.

Furthermore, the system must handle edge cases such as early check-outs requiring prorated billing adjustments, late check-ins after midnight affecting date calculations, room upgrades modifying reservation details, group bookings with special rate negotiations, cancellations triggering refund workflows, and no-shows requiring penalty processing. Integration with external systems like payment gateways for secure transactions, channel managers for distributing inventory across booking platforms, and property management interfaces for building automation adds another layer of complexity that requires careful architectural design and robust error handling.

System Requirements

We’ll focus on the following set of requirements while designing the Hotel Management System:

  1. The system should support the booking of different room types like standard, deluxe, family suite, etc.
  2. Guests should be able to search the room inventory and book any available room.
  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.
  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.
  5. The system should be able to send notifications whenever the booking is nearing the check-in or check-out date.
  6. The system should maintain a room housekeeping log to keep track of all housekeeping tasks.
  7. Any customer should be able to add room services and food items.
  8. Customers can ask for different amenities.
  9. The customers should be able to pay their bills through credit card, check or cash.

Use Case Diagram

Here are the main Actors in our system:

  • Guest: All guests can search the available rooms, as well as make a booking.
  • Receptionist: Mainly responsible for adding and modifying rooms, creating room bookings, check-in, and check-out customers.
  • System: Mainly responsible for sending notifications for room booking, cancellation, etc.
  • Manager: Mainly responsible for adding new workers.
  • Housekeeper: To add/modify housekeeping record of rooms.
  • Server: To add/modify room service record of rooms.

Here are the top use cases of the Hotel Management System:

  • Add/Remove/Edit room: To add, remove, or modify a room in the system.
  • Search room: To search for rooms by type and availability.
  • Register or cancel an account: To add a new member or cancel the membership of an existing member.
  • Book room: To book a room.
  • Check-in: To let the guest check-in for their booking.
  • Check-out: To track the end of the booking and the return of the room keys.
  • Add room charge: To add a room service charge to the customer’s bill.
  • Update housekeeping log: To add or update the housekeeping entry of a room.

Class Diagram

Here are the main classes of our Hotel Management System:

  • Hotel and HotelLocation: Our system will support multiple locations of a hotel.
  • 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.
  • 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.

Problem

Design a Hotel Management System to manage room inventory, bookings, check-in/check-out, housekeeping, room services, billing, and notifications. The system should support different room types, multiple locations, and standard payment/refund rules.

Solution

1. Requirements Analysis

Functional Requirements:

  • Search and book rooms of various types (standard, deluxe, family suite, etc.).
  • Support booking lifecycle: create, modify, cancel (with refund rules).
  • Check-in / check-out flows and room key assignment.
  • Track housekeeping logs and room service charges.
  • Support invoice generation and multiple payment methods.
  • Notify guests about upcoming check-ins/check-outs and booking changes.

Non-Functional Requirements:

  • Consistency for booking and payment transactions.
  • Scalability across locations (hotel chains / multiple properties).
  • Durability for invoices, bookings and housekeeping logs.

Assumptions:

  • Cancellation refund policy: full refund if canceled >24 hours before check-in.

2. Use Case Diagram

Actors: Guest, Receptionist, Manager, Housekeeper, Server, System

Primary Use Cases: Search Room, Book Room, Check-in, Check-out, Add Room Charge, Update Housekeeping

graph TB
    %% Actors
    Guest([Guest])
    Receptionist([Receptionist])
    Manager([Manager])
    Housekeeper([Housekeeper])
    Server([Server])
    System([System])

    %% Guest Use Cases - Discovery & Booking
    subgraph Discovery["Discovery & Search"]
        UC1[Search Rooms by Type]
        UC2[Check Room Availability]
        UC3[View Room Details & Pricing]
        UC4[Compare Room Types]
    end

    subgraph Booking["Booking Management"]
        UC5[Create Reservation]
        UC6[Modify Booking]
        UC7[Cancel Booking]
        UC8[View Booking History]
        UC9[Request Room Upgrade]
    end

    %% Receptionist Use Cases
    subgraph CheckInOut["Check-in/Check-out"]
        UC10[Process Check-in]
        UC11[Process Check-out]
        UC12[Issue Room Key]
        UC13[Deactivate Room Key]
        UC14[Handle Walk-in Guests]
        UC15[Process Early Checkout]
        UC16[Handle Late Checkout]
    end

    subgraph RoomMgmt["Room Management"]
        UC17[Add Room]
        UC18[Remove Room]
        UC19[Edit Room Details]
        UC20[Update Room Status]
        UC21[Assign Room to Booking]
    end

    %% Billing & Payments
    subgraph Billing["Billing & Payments"]
        UC22[Generate Invoice]
        UC23[Process Payment]
        UC24[Apply Refund]
        UC25[Add Room Charges]
        UC26[Calculate Taxes]
        UC27[View Payment History]
    end

    %% Services
    subgraph Services["Guest Services"]
        UC28[Request Room Service]
        UC29[Order Food/Beverages]
        UC30[Request Amenities]
        UC31[Add Service Charges]
        UC32[Update Service Status]
    end

    %% Housekeeping
    subgraph Housekeeping["Housekeeping"]
        UC33[Create Housekeeping Task]
        UC34[Update Housekeeping Log]
        UC35[Mark Room as Clean]
        UC36[Report Maintenance Issues]
        UC37[View Assigned Rooms]
    end

    %% Staff Management
    subgraph StaffMgmt["Staff Management"]
        UC38[Add Employee]
        UC39[Remove Employee]
        UC40[Update Employee Details]
        UC41[Assign Roles & Permissions]
    end

    %% Notifications
    subgraph Notifications["Notifications"]
        UC42[Send Booking Confirmation]
        UC43[Send Check-in Reminder]
        UC44[Send Check-out Reminder]
        UC45[Send Cancellation Notice]
        UC46[Send Payment Receipt]
    end

    %% Actor to Use Case connections - Guest
    Guest --> UC1
    Guest --> UC2
    Guest --> UC3
    Guest --> UC4
    Guest --> UC5
    Guest --> UC6
    Guest --> UC7
    Guest --> UC8
    Guest --> UC9
    Guest --> UC28
    Guest --> UC29
    Guest --> UC30

    %% Actor to Use Case connections - Receptionist
    Receptionist --> UC5
    Receptionist --> UC6
    Receptionist --> UC7
    Receptionist --> UC10
    Receptionist --> UC11
    Receptionist --> UC12
    Receptionist --> UC13
    Receptionist --> UC14
    Receptionist --> UC15
    Receptionist --> UC16
    Receptionist --> UC17
    Receptionist --> UC18
    Receptionist --> UC19
    Receptionist --> UC20
    Receptionist --> UC21
    Receptionist --> UC22
    Receptionist --> UC23
    Receptionist --> UC24
    Receptionist --> UC25
    Receptionist --> UC26

    %% Actor to Use Case connections - Manager
    Manager --> UC17
    Manager --> UC18
    Manager --> UC19
    Manager --> UC38
    Manager --> UC39
    Manager --> UC40
    Manager --> UC41
    Manager --> UC27
    Manager --> UC8

    %% Actor to Use Case connections - Housekeeper
    Housekeeper --> UC33
    Housekeeper --> UC34
    Housekeeper --> UC35
    Housekeeper --> UC36
    Housekeeper --> UC37

    %% Actor to Use Case connections - Server
    Server --> UC28
    Server --> UC29
    Server --> UC31
    Server --> UC32

    %% Actor to Use Case connections - System
    System --> UC42
    System --> UC43
    System --> UC44
    System --> UC45
    System --> UC46

    %% Styling
    classDef actorStyle fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef guestStyle fill:#e1f5e1,stroke:#4caf50,stroke-width:2px
    classDef receptionistStyle fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
    classDef managerStyle fill:#fff3e0,stroke:#ff9800,stroke-width:2px
    classDef housekeeperStyle fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px
    classDef serverStyle fill:#fce4ec,stroke:#e91e63,stroke-width:2px
    classDef systemStyle fill:#e0f2f1,stroke:#009688,stroke-width:2px

    class Guest,Receptionist,Manager,Housekeeper,Server,System actorStyle
    class UC1,UC2,UC3,UC4,UC5,UC6,UC7,UC8,UC9,UC28,UC29,UC30 guestStyle
    class UC10,UC11,UC12,UC13,UC14,UC15,UC16,UC17,UC18,UC19,UC20,UC21,UC22,UC23,UC24,UC25,UC26 receptionistStyle
    class UC38,UC39,UC40,UC41 managerStyle
    class UC33,UC34,UC35,UC36,UC37 housekeeperStyle
    class UC31,UC32 serverStyle
    class UC42,UC43,UC44,UC45,UC46 systemStyle

3. Class Diagram

Key classes and responsibilities:

  • Hotel / HotelLocation: Top-level grouping of rooms and operations per location
  • Room: Represents a physical room with style, status, pricing, and room keys
  • RoomBooking: Manages reservation lifecycle and guest associations
  • Account (Guest, Receptionist, Housekeeper, Server, Manager): Role-based actors with specific permissions
  • RoomCharge (Amenity, RoomService, KitchenService): Different types of charges added to invoices
  • Invoice / InvoiceItem: Billing and payment processing
  • RoomHousekeeping: Tracks housekeeping tasks and schedules
  • RoomKey / KeyCard: Physical access control to rooms
  • Notification: Alert system for booking events
classDiagram
    %% Core Entities
    class Hotel {
        -String name
        -List~HotelLocation~ locations
        +addLocation(HotelLocation)
        +getLocation(String): HotelLocation
    }
    
    class HotelLocation {
        -String name
        -Address address
        -List~Room~ rooms
        +addRoom(Room)
        +getRooms(): List~Room~
    }
    
    class Address {
        -String streetAddress
        -String city
        -String state
        -String zipCode
        -String country
    }
    
    %% Room Management
    class Room {
        -String roomNumber
        -RoomStyle style
        -RoomStatus status
        -double bookingPrice
        -boolean isSmoking
        -List~RoomKey~ keys
        +isRoomAvailable(): boolean
        +checkIn()
        +checkOut()
        +updateStatus(RoomStatus)
    }
    
    class RoomStyle {
        <<enumeration>>
        STANDARD
        DELUXE
        FAMILY_SUITE
        BUSINESS_SUITE
        PRESIDENTIAL_SUITE
    }
    
    class RoomStatus {
        <<enumeration>>
        AVAILABLE
        RESERVED
        OCCUPIED
        NOT_AVAILABLE
        BEING_SERVICED
        OTHER
    }
    
    class RoomKey {
        -String keyId
        -String barcode
        -Date issuedAt
        -boolean isActive
        -boolean isMaster
        +assignRoom(Room)
    }
    
    %% Booking Management
    class RoomBooking {
        -String reservationNumber
        -Date startDate
        -Date durationInDays
        -BookingStatus status
        -Date checkin
        -Date checkout
        -int guestID
        -Room room
        -Invoice invoice
        -List~Notification~ notifications
        +fetchDetails(String): RoomBooking
        +cancel(): boolean
        +modify(Date, int): boolean
    }
    
    class BookingStatus {
        <<enumeration>>
        REQUESTED
        PENDING
        CONFIRMED
        CHECKED_IN
        CHECKED_OUT
        CANCELLED
        ABANDONED
    }
    
    %% Account Management
    class Account {
        <<abstract>>
        -String id
        -String password
        -AccountStatus status
        -Person person
        +resetPassword()
    }
    
    class AccountStatus {
        <<enumeration>>
        ACTIVE
        CLOSED
        CANCELED
        BLACKLISTED
        BLOCKED
    }
    
    class Guest {
        -int totalRoomsCheckedIn
        +searchRooms(RoomStyle, Date, int): List~Room~
        +makeBooking(Room, Date, int): RoomBooking
        +getBookings(): List~RoomBooking~
    }
    
    class Receptionist {
        +searchMember(String): Member
        +createBooking(Guest, Room, Date, int): RoomBooking
        +checkIn(RoomBooking)
        +checkOut(RoomBooking)
    }
    
    class Housekeeper {
        +addRoomCharge(Room, RoomCharge)
        +updateHousekeeping(Room, RoomHousekeeping)
    }
    
    class Server {
        +addRoomService(Room, RoomService)
    }
    
    class Manager {
        +addStaff(Account)
        +getReport(): Report
    }
    
    class Person {
        -String name
        -String email
        -String phone
        -Address address
    }
    
    %% Charges and Billing
    class RoomCharge {
        <<abstract>>
        -Date issueAt
        +addInvoiceItem(Invoice)
    }
    
    class Amenity {
        -String name
        -String description
    }
    
    class RoomService {
        -boolean isChargeable
        -Date requestTime
    }
    
    class KitchenService {
        -String description
    }
    
    class Invoice {
        -String invoiceId
        -double amount
        -List~InvoiceItem~ items
        +createBill(): boolean
        +addItem(InvoiceItem)
    }
    
    class InvoiceItem {
        -String description
        -double amount
        -Date chargeDate
    }
    
    %% Payment
    class Payment {
        <<abstract>>
        -double amount
        -Date timestamp
        -PaymentStatus status
        +initiateTransaction(): boolean
    }
    
    class PaymentStatus {
        <<enumeration>>
        PENDING
        COMPLETED
        FAILED
        REFUNDED
    }
    
    class CreditCard {
        -String nameOnCard
        -String cardNumber
        -String billingAddress
        -int code
    }
    
    class Cash {
        -double cashTendered
    }
    
    class Check {
        -String bankName
        -String checkNumber
    }
    
    %% Housekeeping
    class RoomHousekeeping {
        -String description
        -Date startDate
        -int duration
        -Housekeeper housekeeper
        +addHousekeeping(Room)
    }
    
    %% Notifications
    class Notification {
        -int notificationId
        -Date createdOn
        -String content
        +sendNotification(Account)
    }
    
    class SMSNotification {
        -String phoneNumber
    }
    
    class EmailNotification {
        -String email
    }
    
    %% Relationships
    Hotel "1" *-- "many" HotelLocation : contains
    HotelLocation "1" o-- "1" Address : has
    HotelLocation "1" *-- "many" Room : manages
    
    Room "1" -- "1" RoomStyle : has
    Room "1" -- "1" RoomStatus : has
    Room "1" *-- "many" RoomKey : issued
    Room "1" o-- "many" RoomBooking : has bookings
    Room "1" o-- "many" RoomHousekeeping : has logs
    
    RoomBooking "1" -- "1" BookingStatus : has
    RoomBooking "many" -- "1" Guest : made by
    RoomBooking "1" *-- "1" Invoice : generates
    RoomBooking "1" *-- "many" Notification : sends
    
    Account <|-- Guest : extends
    Account <|-- Receptionist : extends
    Account <|-- Housekeeper : extends
    Account <|-- Server : extends
    Account <|-- Manager : extends
    Account "1" -- "1" AccountStatus : has
    Account "1" o-- "1" Person : represents
    
    Person "1" o-- "1" Address : lives at
    
    RoomCharge <|-- Amenity : extends
    RoomCharge <|-- RoomService : extends
    RoomCharge <|-- KitchenService : extends
    
    Invoice "1" *-- "many" InvoiceItem : contains
    Invoice "1" o-- "1" Payment : paid via
    
    Payment <|-- CreditCard : extends
    Payment <|-- Cash : extends
    Payment <|-- Check : extends
    Payment "1" -- "1" PaymentStatus : has
    
    Notification <|-- SMSNotification : extends
    Notification <|-- EmailNotification : extends
    
    RoomHousekeeping "many" -- "1" Housekeeper : assigned to

4. Activity Diagrams

Activity 1: Make a Room Booking

flowchart TD
    Start([Guest Initiates Booking]) --> SearchRooms[Search Available Rooms]
    SearchRooms --> CheckAvailability{Rooms<br/>Available?}
    
    CheckAvailability -->|No| NotifyUnavailable[Notify Guest:<br/>No Rooms Available]
    NotifyUnavailable --> End1([End])
    
    CheckAvailability -->|Yes| DisplayRooms[Display Available<br/>Rooms & Prices]
    DisplayRooms --> SelectRoom[Guest Selects<br/>Room & Dates]
    SelectRoom --> CreateBooking[Create Booking<br/>Object]
    CreateBooking --> HoldRoom[Mark Room as<br/>RESERVED]
    HoldRoom --> CalculatePrice[Calculate Total<br/>Price]
    CalculatePrice --> ProcessPayment[Process Payment/<br/>Hold Deposit]
    
    ProcessPayment --> PaymentSuccess{Payment<br/>Successful?}
    
    PaymentSuccess -->|No| ReleaseRoom[Release Room<br/>Status to AVAILABLE]
    ReleaseRoom --> NotifyFailure[Notify Guest:<br/>Payment Failed]
    NotifyFailure --> End2([End])
    
    PaymentSuccess -->|Yes| ConfirmBooking[Update Booking<br/>to CONFIRMED]
    ConfirmBooking --> GenerateConfirmation[Generate Confirmation<br/>Number]
    GenerateConfirmation --> SendConfirmation[Send Confirmation<br/>Email/SMS]
    SendConfirmation --> ScheduleReminder[Schedule Check-in<br/>Reminder]
    ScheduleReminder --> UpdateInventory[Update Room<br/>Inventory]
    UpdateInventory --> End3([End: Booking Complete])
    
    style Start fill:#e1f5e1
    style End1 fill:#ffe1e1
    style End2 fill:#ffe1e1
    style End3 fill:#e1f5e1
    style CheckAvailability fill:#fff4e1
    style PaymentSuccess fill:#fff4e1
    style ConfirmBooking fill:#e1e5ff
    style SendConfirmation fill:#e1e5ff

Activity 2: Check-in Process

flowchart TD
    Start([Guest Arrives at Front Desk]) --> RetrieveBooking[Receptionist Retrieves<br/>Booking by Confirmation#]
    RetrieveBooking --> ValidBooking{Valid<br/>Booking?}
    
    ValidBooking -->|No| CreateWalkIn[Create Walk-in<br/>Booking]
    CreateWalkIn --> CheckRoomAvail{Room<br/>Available?}
    CheckRoomAvail -->|No| Apologize[Apologize to Guest]
    Apologize --> End1([End])
    CheckRoomAvail -->|Yes| AssignRoom
    
    ValidBooking -->|Yes| VerifyID[Verify Guest ID<br/>Documents]
    VerifyID --> ValidID{ID Valid?}
    ValidID -->|No| RequestValidID[Request Valid ID]
    RequestValidID --> VerifyID
    
    ValidID -->|Yes| CheckPayment{Payment<br/>Complete?}
    CheckPayment -->|No| CollectPayment[Collect Remaining<br/>Payment]
    CollectPayment --> PaymentOK{Payment<br/>Successful?}
    PaymentOK -->|No| End2([End: Payment Failed])
    PaymentOK -->|Yes| AssignRoom
    
    CheckPayment -->|Yes| AssignRoom[Assign Physical<br/>Room]
    AssignRoom --> IssueKey[Issue Room Key/<br/>KeyCard]
    IssueKey --> UpdateBooking[Update Booking<br/>Status to CHECKED_IN]
    UpdateBooking --> RecordCheckin[Record Check-in<br/>Timestamp]
    RecordCheckin --> InformGuest[Inform Guest about<br/>Amenities & Checkout]
    InformGuest --> NotifyHousekeeping[Notify Housekeeping:<br/>Room Occupied]
    NotifyHousekeeping --> ScheduleCheckout[Schedule Checkout<br/>Reminder]
    ScheduleCheckout --> End3([End: Guest Checked-In])
    
    style Start fill:#e1f5e1
    style End1 fill:#ffe1e1
    style End2 fill:#ffe1e1
    style End3 fill:#e1f5e1
    style ValidBooking fill:#fff4e1
    style CheckRoomAvail fill:#fff4e1
    style ValidID fill:#fff4e1
    style CheckPayment fill:#fff4e1
    style PaymentOK fill:#fff4e1
    style UpdateBooking fill:#e1e5ff
    style IssueKey fill:#e1e5ff

Activity 3: Check-out and Billing

flowchart TD
    Start([Guest Initiates Checkout]) --> RetrieveBooking[Retrieve Booking<br/>Record]
    RetrieveBooking --> CalculateCharges[Calculate Total<br/>Charges]
    CalculateCharges --> AddRoomRate[Add Room Rate]
    AddRoomRate --> CheckServices{Additional<br/>Services?}
    
    CheckServices -->|Yes| AddServiceCharges[Add Service Charges:<br/>Room Service, Amenities]
    AddServiceCharges --> CheckTax
    CheckServices -->|No| CheckTax{Apply<br/>Taxes?}
    
    CheckTax -->|Yes| CalculateTax[Calculate & Add<br/>Taxes]
    CalculateTax --> GenerateInvoice
    CheckTax -->|No| GenerateInvoice[Generate Final<br/>Invoice]
    
    GenerateInvoice --> DisplayInvoice[Display Invoice<br/>to Guest]
    DisplayInvoice --> GuestReview{Guest<br/>Approves?}
    
    GuestReview -->|Dispute| ResolveDispute[Resolve Disputed<br/>Charges]
    ResolveDispute --> GenerateInvoice
    
    GuestReview -->|Approved| ProcessPayment[Process Final<br/>Payment]
    ProcessPayment --> PaymentSuccess{Payment<br/>Successful?}
    
    PaymentSuccess -->|No| RetryPayment{Retry or<br/>Alternative Method?}
    RetryPayment -->|Retry| ProcessPayment
    RetryPayment -->|Cancel| HoldCheckout[Hold Checkout:<br/>Payment Pending]
    HoldCheckout --> End1([End: Pending])
    
    PaymentSuccess -->|Yes| UpdateBooking[Update Booking<br/>Status to CHECKED_OUT]
    UpdateBooking --> DeactivateKey[Deactivate Room<br/>Key/KeyCard]
    DeactivateKey --> ReleaseRoom[Release Room &<br/>Mark as BEING_SERVICED]
    ReleaseRoom --> NotifyHousekeeping[Notify Housekeeping:<br/>Room Ready for Cleaning]
    NotifyHousekeeping --> SendReceipt[Send Receipt via<br/>Email]
    SendReceipt --> CheckLoyalty{Loyalty<br/>Member?}
    
    CheckLoyalty -->|Yes| UpdatePoints[Update Loyalty<br/>Points]
    UpdatePoints --> ThankGuest
    CheckLoyalty -->|No| ThankGuest[Thank Guest &<br/>Request Feedback]
    
    ThankGuest --> End2([End: Checkout Complete])
    
    style Start fill:#e1f5e1
    style End1 fill:#ffe1e1
    style End2 fill:#e1f5e1
    style CheckServices fill:#fff4e1
    style CheckTax fill:#fff4e1
    style GuestReview fill:#fff4e1
    style PaymentSuccess fill:#fff4e1
    style RetryPayment fill:#fff4e1
    style CheckLoyalty fill:#fff4e1
    style UpdateBooking fill:#e1e5ff
    style DeactivateKey fill:#e1e5ff
    style NotifyHousekeeping fill:#e1e5ff

5. High-Level Code Implementation

Short Python and Java skeletons capturing the main types and method signatures.

Python (skeleton)

from enum import Enum
from typing import List


class RoomStyle(Enum):
    STANDARD = 1
    DELUXE = 2
    FAMILY_SUITE = 3
    BUSINESS_SUITE = 4


class RoomStatus(Enum):
    AVAILABLE = 1
    RESERVED = 2
    OCCUPIED = 3


class Room:
    def __init__(self, room_number: int, style: RoomStyle, price: float):
        self._room_number = room_number
        self._style = style
        self._price = price
        self._status = RoomStatus.AVAILABLE

    def is_available(self) -> bool:
        return self._status == RoomStatus.AVAILABLE


class RoomBooking:
    def __init__(self, reservation_number: str, guest_id: str, start_date, duration_days: int):
        self.reservation_number = reservation_number
        self.guest_id = guest_id
        self.start_date = start_date
        self.duration_days = duration_days
        self.status = None


class Hotel:
    def __init__(self, name: str):
        self._name = name
        self._locations = []

    def add_location(self, location):
        pass


class BookingService:
    def create_booking(self, guest_id: str, room_style: RoomStyle, start_date, duration: int) -> RoomBooking:
        pass

Java (skeleton)

public enum RoomStatus { AVAILABLE, RESERVED, OCCUPIED }

public class Room {
    private int roomNumber;
    private RoomStatus status;
}

public class RoomBooking {
    private String reservationNumber;
    private BookingStatus status;
}

public class BookingService {
    public RoomBooking createBooking(String guestId, RoomStyle style, Date start, int duration) { return null; }
}

Appendix — Original code

The original detailed examples (enums, Account/Person, Room, RoomBooking, RoomCharge) are preserved below for reference and for use when turning this note into a runnable demo or tests.

from enum import Enum


class RoomStyle(Enum):
    STANDARD, DELUXE, FAMILY_SUITE, BUSINESS_SUITE = 1, 2, 3, 4


class RoomStatus(Enum):
    AVAILABLE, RESERVED, OCCUPIED, NOT_AVAILABLE, BEING_SERVICED, OTHER = 1, 2, 3, 4, 5, 6


class BookingStatus(Enum):
    REQUESTED, PENDING, CONFIRMED, CHECKED_IN, CHECKED_OUT, CANCELLED, ABANDONED = 1, 2, 3, 4, 5, 6, 7


class AccountStatus(Enum):
    ACTIVE, CLOSED, CANCELED, BLACKLISTED, BLOCKED = 1, 2, 3, 4, 5


class AccountType(Enum):
    MEMBER, GUEST, MANAGER, RECEPTIONIST = 1, 2, 3, 4


class PaymentStatus(Enum):
    UNPAID, PENDING, COMPLETED, FILLED, DECLINED, CANCELLED, ABANDONED, SETTLING, SETTLED, REFUNDED = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10


class Address:
    def __init__(self, street, city, state, zip_code, country):
        self.__street_address = street
        self.__city = city
        self.__state = state
        self.__zip_code = zip_code
        self.__country = country


from abc import ABC
from .constants import *


# For simplicity, we are not defining getter and setter functions. The reader can
# assume that all class attributes are private and accessed through their respective
# public getter methods and modified only through their public methods function.

class Account:
    def __init__(self, id, password, status=AccountStatus.Active):
        self.__id = id
        self.__password = password
        self.__status = status

    def reset_password(self):
        None


# from abc import ABC, abstractmethod
class Person(ABC):
    def __init__(self, name, address, email, phone, account):
        self.__name = name
        self.__address = address
        self.__email = email
        self.__phone = phone
        self.__account = account


class Guest(Person):
    def __init__(self):
        self.__total_rooms_checked_in = 0

    def get_bookings(self):
        None


class Receptionist(Person):
    def search_member(self, name):
        None

    def create_booking(self):
        None


class Server(Person):
    def add_room_charge(self, room, room_charge):
        None


class HotelLocation:
    def __init__(self, name, address):
        self.__name = name
        self.__location = address

    def get_rooms(self):
        None


class Hotel:
    def __init__(self, name):
        self.__name = name
        self.__locations = []

    def add_location(self, location):
        None


from datetime import datetime
from abc import ABC


class Search(ABC):
    def search(self, style, start_date, duration):
        None


class Room(Search):
    def __init__(self, room_number, room_style, status, price, is_smoking):
        self.__room_number = room_number
        self.__style = room_style
        self.__status = status
        self.__booking_price = price
        self.__is_smoking = is_smoking

        self.__keys = []
        self.__house_keeping_log = []

    def is_room_available(self):
        None

    def check_in(self):
        None

    def check_out(self):
        None

    def search(self, style, start_date, duration):
        None


class RoomKey:
    def __init__(self, key_id, barcode, is_active, is_master):
        self.__key_id = key_id
        self.__barcode = barcode
        self.__issued_at = datetime.date.today()
        self.__active = is_active
        self.__is_master = is_master

    def assign_room(self, room):
        None

    def is_active(self):
        None


class RoomHouseKeeping:
    def __init__(self, description, duration, house_keeper):
        self.__description = description
        self.__start_datetime = datetime.date.today()
        self.__duration = duration
        self.__house_keeper = house_keeper

    def add_house_keeping(self, room):
        None


class RoomBooking:
    def __init__(self, reservation_number, start_date, duration_in_days, booking_status):
        self.__reservation_number = reservation_number
        self.__start_date = start_date
        self.__duration_in_days = duration_in_days
        self.__status = booking_status
        self.__checkin = None
        self.__checkout = None

        self.__guest_id = 0
        self.__room = None
        self.__invoice = None
        self.__notifications = []

    def fetch_details(self, reservation_number):
        None


# from abc import ABC, abstractmethod
class RoomCharge(ABC):
    def __init__(self):
        self.__issue_at = datetime.date.today()

    def add_invoice_item(self, invoice):
        None


class Amenity(RoomCharge):
    def __init__(self, name, description):
        self.__name = name
        self.__description = description


class RoomService(RoomCharge):
    def __init__(self, is_chargeable, request_time):
        self.__is_chargeable = is_chargeable
        self.__request_time = request_time


class KitchenService(RoomCharge):
    def __init__(self, description):
        self.__description = description


class RoomHousekeeping:
    def __init__(self, description, duration):
        self.__description = description
        self.__duration = duration
        self.__housekeeper = None

    def add_housekeeping(self, room):
        pass


## 7. Key Design Decisions

1. **State Pattern for Room Status Management**: Implemented RoomStatus enum and state transitions to prevent invalid state changes (e.g., cannot book a room under maintenance).

2. **Strategy Pattern for Pricing**: Different room styles have different pricing strategies. This allows dynamic pricing based on season, occupancy, or customer type.

3. **Repository Pattern for Data Access**: Separate data access logic from business logic using repository interfaces for rooms, bookings, and invoices.

4. **Command Pattern for Booking Operations**: Encapsulate booking requests as command objects to support undo/redo and transaction logging.

5. **Observer Pattern for Notifications**: Notify multiple systems (email, SMS, mobile app) when booking status changes without tight coupling.

6. **Factory Pattern for Payment Processing**: Create different payment processors (CreditCard, Cash, Check) using a factory to handle various payment methods.

7. **Decorator Pattern for Room Amenities**: Add amenities dynamically to rooms without modifying the Room class structure.

8. **Template Method for Check-in/Check-out Flow**: Define the skeleton of check-in/check-out algorithm with customizable steps for different room types.

9. **Chain of Responsibility for Refund Rules**: Process refund requests through a chain of validators (date check, payment status, cancellation policy).

10. **Facade Pattern for External Integrations**: Provide simplified interfaces to complex subsystems like payment gateways and notification services.

Comments