Design an online hotel booking system like OYO Rooms

We need to design an online hotel booking system where a user can search a hotel in a given city and book it. This is an OOP design question, so I have not written the full code in this solution. I have created the classes and attributes only.

Solution :

Main Classes :

1. User
2. Room
3. Hotel
4. Booking
5. Address
6. Facilities

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code skeleton to design an online hotel
// booking system.
Enums:
  
public enum RoomStatus {
    EMPTY
        NOT_EMPTY;
}
  
public enum RoomType {
    SINGLE,
    DOUBLE,
    TRIPLE;
}
  
public enum PaymentStatus {
    PAID,
    UNPAID;
}
  
public enum Facility {
    LIFT;
    POWER_BACKUP;
    HOT_WATERR;
    BREAKFAST_FREE;
    SWIMMING_POOL;
}
  
class User {
  
    int userId;
    String name;
    Date dateOfBirth;
    String mobNo;
    String emailId;
    String sex;
}
  
// For the room in any hotel
class Room {
  
    int roomId; // roomNo
    int hotelId;
    RoomType roomType;
    RoomStatus roomStatus;
}
  
class Hotel {
  
    int hotelId;
    String hotelName;
    Adress adress;
  
    // hotel contains the list of rooms
    List<Room> rooms;
    float rating;
    Facilities facilities;
}
  
// a new booking is created for each booking 
// done by any user
class Booking {
    int bookingId;
    int userId;
    int hotelId;
  
    // We are assuming that in a single 
    // booking we can book only the rooms 
    // of a single hotel
    List<Rooms> bookedRooms; 
      
    int amount;
    PaymentStatus status_of_payment;
    Date bookingTime;
    Duration duration;
}
  
class Address {
  
    String city;
    String pinCode;
    String state;
    String streetNo;
    String landmark;
}
  
class Duration {
  
    Date from;
    Date to;
  
}
  
class Facilities {
  
    List<Facility> facilitiesList;
}

chevron_right


Let me explain about the classes and the relationships among themselves.

The enums defined here are self-explanatory. The classes User, Room, and Address also self-explanatory. The class Facilities contains a list of facilities (enum) that the hotel provides. We can add more facilities in the Facility enum if required. The duration class has two attributes “from” and “to”, which is obvious.

Now, the class “Hotel” contains:
1. List of rooms (Room class) // this is the list of rooms the hotel has
2. Address class // its address
3. Facilities class // the facilities it has

The class “Booking” contains:
1. User // information about the
2. Hotel // Information about the hotel
3. List of rooms
4. PaymentStatus etc.

Other fields in this class are also self-explanatory.

This article is contributed by Pooja Kamal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.