Question: IN JAVA PLEASE: 9) The class below is supposed to model a door with a lock (can only be opened if it is not locked).
IN JAVA PLEASE:

9) The class below is supposed to model a door with a lock (can only be opened if it is not locked). What is the main problem with this implementation? Explain briefly and fix it. public class Door { // Locks the door (it can be locked whether open or not) public void lockDoor() boolean isLocked = true; } // Unlocks the door (it can be unlocked whether open or not) public void unlockDoor () { isLocked = false; } // closes the door (it can be closed whether locked or not) public void closeDoor() boolean open = false; } // Opens the door, only if it is not locked. public void openDoor () { if (!isLocked) { open = true; } // Determines whether the door is open or not public boolean isOpen() { return open; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
