The ElevatorSystem is a simulation of a basic elevator control system. This project demonstrates object-oriented design principles including inheritance, composition, aggregation, and the singleton pattern.
-
Inheritance
ElevatorButtonandHallButtoninherit fromButton.
-
Composition
BuildingcontainsFloorobjects.FloorcontainsHallPanelandDisplayobjects.ElevatorcontainsDoor,Display, andElevatorPanelobjects.
-
Aggregation
BuildingaggregatesElevatorobjects.ElevatorPanelaggregatesElevatorButtonobjects.
-
Singleton Pattern
BuildingandElevatorSystemuse the singleton pattern to ensure only one instance exists.
The system consists of several interconnected classes that simulate the behavior of an elevator system in a building:
- Building: Singleton class that manages multiple floors and elevators.
- Floor: Represents a floor in the building, containing hall panels and displays.
- HallPanel: Contains up and down buttons to call the elevator.
- Elevator: Manages the state and behavior of an individual elevator, including doors, displays, and buttons.
- ElevatorPanel: Contains buttons inside the elevator to select destination floors and open/close doors.
- Display: Shows the current floor and direction of the elevator.
- Button: Abstract base class for all buttons in the system.
- ElevatorButton: Button inside the elevator for selecting floors.
- HallButton: Button on the floor to call the elevator in a specific direction.
- ElevatorSystem: Singleton class that monitors and controls the elevator system.
Here is a sample output demonstrating how the system operates:
Monitoring the elevator system...
Elevator 0 moving from floor 0 to floor 5.
Door is now Open.
Door is now Closed.
Elevator 1 moving from floor 0 to floor 9.
Door is now Open.
Door is now Closed.
Hall button for direction UP pressed.
Elevator button for floor 5 pressed.
Elevator 0 moving from floor 0 to floor 5.
Door is now Open.
Door is now Closed.
Hall button for direction Down pressed.
Elevator button for floor 0 pressed.
Elevator 1 moving from floor 9 to floor 0.
Door is now Open.
Door is now Closed.
