Answered step by step
Verified Expert Solution
Question
1 Approved Answer
must follow format of 2nd photo. IN JAVA. Create an implementation for the class DoorLock described below. 1. declare an integer constant, called MAX_NUMBER_OF_ATTEMPTS, that
must follow format of 2nd photo.
IN JAVA.
Create an implementation for the class DoorLock described below. 1. declare an integer constant, called MAX_NUMBER_OF_ATTEMPTS, that you will initialize to the value 3 ; 2. instance variables. The class DoorLock 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 activation state (the door lock is activated or deactivated), and iv. to count the number of unsuccessful attempts at opening the door; number of failed attempts at opening it should be zero; 4. implement the instance method public boolean isOpen() that returns true if this door lock is currently opened and false otherwise; 5. implement the instance method public boolean isActivated() that returns true if this door lock is currently activated and false otherwise; 7. finally, implement the instance method public boolean open(Combination combination) such that i. an attempt is made at opening this door lock only if this door lock is activated 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 deactivated. Hint: my implementation is approximately 40 lines long, not counting the blank linesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started