Improved readability of Elevator Movement Algorithm. Elevator now displays both "IDLE" and "ACTIVE" Movement states in its output statements.
There's a slight bug where, when an elevator is IDLE and currentFloor == requestFloor, the "reached destination" message pops up before the "moved to floor" message. This is because the first time the "compareFloor()" method is called in "respondToRequest()," it checks if the elevator is stopped and removes the request if that happens.
Changes
Elevator: moved logic for run method into new method respondToRequest()
Elevator: simplified compareFloors() method and moveElevatorWhilePossible methods
Elevator: added startMovingTowardsFloor() and stopAtFloor() methods
Improved readability of Elevator Movement Algorithm. Elevator now displays both "IDLE" and "ACTIVE" Movement states in its output statements.
There's a slight bug where, when an elevator is IDLE and currentFloor == requestFloor, the "reached destination" message pops up before the "moved to floor" message. This is because the first time the "compareFloor()" method is called in "respondToRequest()," it checks if the elevator is stopped and removes the request if that happens.
Changes