Hello @Yash_Prajapati,
The openButton
and closeButton
in the ElevatorPanel
are instances of the ElevatorButton
class, which indeed has an attribute destinationFloorNumber
. However, for the openButton
and closeButton
, the destination floor is not relevant, as they are meant for controlling the opening and closing of the elevator doors, not selecting a specific floor.
To address this, we need to create a separate class for buttons specifically for opening and closing doors without the destination floor attribute. For example:
public class DoorButton extends Button {
// No destination floor attribute needed for door buttons
public boolean isPressed() {
// Definition
}
}
public class ElevatorPanel {
private List<ElevatorButton> floorButtons;
private DoorButton openButton;
private DoorButton closeButton;
}
This way, we clearly distinguish between buttons used for floor selection (ElevatorButton
) and door control (DoorButton
). FYI, I have also updated the lesson accordingly.
Happy Learning