...

/

Class Diagram for the Elevator System

Class Diagram for the Elevator System

Learn to create a class diagram for the elevator system problem using the bottom-up approach.

In this lesson, we’ll identify and design the classes, abstract classes, and interfaces based on the requirements we previously gathered from the interviewer in our elevator system.

Components of an elevator system

As mentioned, we will design the elevator system using a bottom-up approach. Therefore, we will first identify and design classes for the smaller components like Button, Door, and Floor. Then, we will create the larger components—ElevatorCar, Building, and finally the overall ElevatorSystem—composed of or aggregates the smaller ones.

Button

Button is an abstract class. There can be four types of buttons: the door button, the elevator button, the hall button, and the emergency stop button. The status of the button determines whether it is pressed or unpressed. We can press the button or check its status through the Button class.

The ElevatorButton subclass is inherited from the Button class and represents the buttons inside the elevator. When the elevator button is pressed, it specifies the destination floor of the elevator car or where the passenger wants to go.

Similar to ElevatorButton, HallButton is also a subclass of the Button class. This class represents the buttons that are outside the elevator. This class used the enumeration Direction to specify whether the button is for going up or down. The hall button has two important pieces of information, the floor from where the button is pressed and the direction in which the passenger wants to move.

Furthermore, there’s an EmergencyButton class that also inherits the behavior of the abstract Button class. This class responds to the passengers call when they press the emergency button. It alerts the support team to take prompt action and refrains other passengers from using the elevator car.

The UML representation of these classes is shown below: