Class Diagram for the Car Rental System
Learn to create a class diagram for the car rental system problem using the bottom-up approach.
Now, we’ll create the class diagram for the car rental system on the basis of the given requirements. In the class diagram, we will first identify classes (concrete, abstract, or associated) and interfaces for the system. Then, we will determine the relationship between them, according to the requirements in the previous lesson.
Components of a car rental system
As mentioned earlier, we’ll design the car rental system using a bottom-up approach.
Address and person
The Address
is a custom data type that is required to store any address. The Address
contains attributes like a street address, city, state, etc. In the car rental system, this class will be used to specify the address of any person or a car rental location or branch. The Person
class stores information related to a person like a name, email, phone number, and address. In the Person
class, there is an object of the Address
type to specify the person’s address. The class representation of Address
and Person
is given below:
Account
Account
is an abstract class that is used to store the account information of a person. This class has members like account ID, password, the status of an account, etc. There can be two types of accounts, i.e., customer and receptionist. The Customer
class represents the customers who reserve the vehicle for themselves, while the Receptionist
class represents the receptionist in the car rental system. Both of them can create any vehicle reservation and can cancel the reservation as well. The class representation of Account
and its subclasses is given below:
Driver
Since we are designing the car rental problem, we will have a Driver
class. A customer can request an additional driver at the time of reservation. The class diagram is shown below:
Vehicle
Our car rental system should have a vehicle object according to the requirements. The vehicle can be of four types: a car, truck, van, and motorcycle. For this purpose, we’ll create Vehicle
as an abstract class and Car
, Truck
, Van
, and Motorcycle
as its subclasses, as shown in the figure below:
Equipment
Equipment
is an abstract class that stores information about different types of equipment that can be added to the reservation. For simplicity, we’ll assume three types of equipment, i.e., navigation, child seat, and ski rack. The ...
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.