Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the class Security Agent described below. instance variables. A security agent is responsible for a particular door lock. Declare the necessary instance variables such
Implement the class Security Agent described below. instance variables. A security agent is responsible for a particular door lock. Declare the necessary instance variables such that a Security Agent remembers (stores) a Combination and has access to this particular Door lock, i.e. maintains a reference to a Door lock object; implement a constructor with no parameter such that when a new Security Agent is created it creates a new Combination and stores it, it creates a new Door lock with this saved Combination .For the sake of simplicity, you may decide to always use the same combination: Combination secret; Secret = new combination (1, 2, 3); if secret is the name of the instance variable that is used to remember the Combination. Or, you can let your Security Agents use their imagination, so that each Security Agent has a new Combination that it only knows. Int first, second, third; first =(int)(math. random() + 5 + 1; second =(int)(math. random() + 5 + 1; third =(int)(math.random() + 5 + 1; Secret = new combination(first, second, third)Alternative way to generate a random combination: java.util.Random generator; generator = new java. Utill. Random(); Int first, second, third; First = generator. next Int(5) + 1; second = generator. next Int(5) + 1; third = generator. next Int(5) + 1;The valid values are within the interval 1 to 5. implement the instance method public Door Lock get Door Lock() that returns a reference to the saved Door Lock; implement the instance method public void activate Door lock() that simply reactivates the particular Door Lock that this Security Agent is responsible for, with the saved secret Combination
Step 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