Question: This is a java lab question2.3. Please help me to get the answer ASAP. Create an implementation for the class DoorLock described below. Declare an

 This is a java lab question2.3. Please help me to get

This is a java lab question2.3. Please help me to get the answer ASAP.

Create an implementation for the class DoorLock described below. Declare an integer constant, called MAXNUMBER_OF_ATTEMPTS, that you will initialize to the value 6 Instance variables. The class Door Lock must have the necessary instance variables to: I Store an object of the class Combination II To represent the property of being opened or closed III To represent its state (the door lock is enabled or disabled) IV To count the number of unsuccessful attempts at opening the door; The class has a single constructor, DoorLock(Combination which initializes this instance with a combination. When a door lock is first created, the door lock is closed. Also, when the object is first created, it is enabled and the number of failed attempts at opening it should be Zero Implement the instance method public boolean isOpen() that returns true if this door lock is currently opened and false otherwise Implement the instance method public boolean is Enabled() that returns true if this door lock is currently enabled and false otherwise. Implement the instance method public void enable(Combination c) that sets the instance variable enabled to true if the parameter c is equals to the combination of this object; Finally, implement the instance method public boolean open(Combination) such that I An attempt is made at opening this door lock only if this door lock is enabled II If the parameter combination is equals to the combination of this door lock, set the state of the door to be open, and the number of failed attempts should be reset to zero III otherwise, i e. if the wrong Combination was supplied, the number of failed attempts should be incremented by one IV If the number of failed attempts reaches MAX_NUMBER_OF_ATTEMPTS, this door lock should be disabled

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!