Class diagram for Hotel management system
Class diagram is a type of UML diagram which shows the properties and relationships among various objects.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
The classes used in this system are,
- Hotel Management : This class depicts the entire hotel and says whether the hotel is opened or closed.
- Employees : It contains the details of the Employee. There are two kinds of employees, Server and the chef. This employee class is the parent class of two subclass – Server and Chef
- Server : It contains the details of the server, the table to which they are assigned, the order which is currently serving, etc.
- Chef : It contains the details of the chef working on a particular order.
- Customer : It contains the details of the customer.
- Table : It contains the table details like table number and the server who are assigned to that table.
- Menu : Menu contains all the food items available in the restaurant, their availability, prize, etc.
- Order : Order depicts the order associated with a particular table and the customer.
- Bill : Bill is calculated using the order and menu.
- Payment : This class is for doing payment. The payment can be done in two ways either cash or card. So payment is the parent class and cash and card are subclasses.
- Cash : Payment can be done by cash
- Card : Payment can be done by card or online
- Hotel Management – HotelName, NumberOfEmployees
- Employees – EmployeeId, EmployeeName, EmployeeSalary
- Server – ServerId, OrderId
- Chef – Chef_Id, OrderId
- Customer – CustomerId, CustomerName, Bill_Id, OrderId, PaymentId
- Table – TableNumber, OccupiedStatus, ServerId, CustomerId
- Menu – ItemId, ItemName, Amount
- Order – OrderId, ItemId, ItemName, Quantity, CustomerId, ServerId
- Bill – Bill_Id, OrderId, TotalBill
- Payment – PaymentId, Bill_Id
1. Hotel Management :
- open() -This is used to indicate if the hotel is functioning or not.
2. Employees :
- employee details() – This method contains the details of the employee.
3. Customer :
- customer_details() – This depicts the details of the customer.
- ordered_items() – This method contains the items which are ordered by the customer.
- payment_status() -This says whether the customer paid or not.
4. Table :
- table_details() – This method contains the details of the table along with the customer and no of seats.
- availability_status() – This method says whether the table is occupied or not.
5. Menu :
- items() – This method displays the menu items, their availability and their price.
6. Order :
- order_items() – This method orders the items selected by the user from the menu.
7. Bill :
- calculate_bill() – This method calculates the bill for a particular table.
8. Payment :
- ispaid() – It shows whether payment is successful or not.
Inheritance is “is a relationship”. It has a parent class and its corresponding child classes. The child class inherits the methods and attributes which are required for it from the parent class.
Here, Employee is parent class Server and Chef are child classes because server is a employee and chef is a employee.
In Association, both classes are related to each other but are not physically contained with one another. It is known as “using” relation. In association relation, consider we have two classes A and B where class A calls class B and Class B also calls class A.
- Employee and customer
- Server and table
- Customer and payment
- Chef and order
follows association relationships.
It is also called as “Has a” relationship where class A has an instance of class B, Class B is composed inside class A and cannot exist independently without class A. So in composition one class is entirely dependent on another class and is physically contained inside it.
- Menu and Order
- Order and Bill
- Bill and Payment
follows composition relation
Order cannot exist without Menu, Bill cannot exist without order and payment cannot exist without bill. So here order is contained inside the menu, bill is contained inside the order and payment is contained inside the bill.
It is also called as “Has a” relationship where class A has an instance of class B, but class B is not composed inside class A and can exist independently without class A. So in aggregation, both the classes depend on each other and use each other but none of them are contained inside one another.
- Customer and Server
- Chef and Server
follows Aggregation relation
Server is associated with the customer but can exist without the customer as well, Likewise Chef is associated with the server but can exist without the server as well.
Class Diagram :