Class Diagram for the Hotel Management System
Learn to create a class diagram for the hotel management system problem using the bottom-up approach.
Here, we are going to create the class diagram for our system on the basis of requirements that we gathered in one of the previous lessons. In the class diagram, we will first design and create the classes, abstract classes, and interfaces for the system, and then we’ll identify the relationship between classes in accordance with all the requirements of the hotel management system.
Components of a hotel management system
In this section, we’ll define the classes for a hotel management system. Since we are following the bottom-up approach to designing a class diagram, we will create the classes of small components first. Next, we will integrate these components and create the class diagram for the entire hotel management system.
Address and Account
The Address
is a class that is required to store any address. The Address
is a custom data type that has attributes like a street address, city, etc. In the hotel management system, this class will be used to specify the address of the users and the hotel.
Account
is a class that is used to store the account information of the user. This class has three members, i.e., account ID, password, and the status of the account. The class representation of Address
and Account
classes is as follows:
Person
Person
is an abstract class used to store information related to a person like a name, email, phone number, etc. In this class, there is an object of the Address
type to specify the person’s address. The Person
class specifies the accounts in the system. There can be four types of accounts in the system,i.e., housekeeper, receptionist, guest, and server.
There are multiple functions of the Person
class’s subclasses. First, the Housekeeper
class will keep track of the housekeeping records of a room. Second, the Receptionist
class represents the hotel receptionist. The methods in this class depict the actions that can be performed by the receptionist. Moreover, the Guest
class describes the guests of the hotel. Guests are the customers of the hotel who can search for and book a room. Whereas, the Server
class will handle the room service.
The relationship diagram for these classes is shown below:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.