Question: Create a Java class that represents a combination lock. The class should include the following: an instance variable to represent the combination: this might be
Create a Java class that represents a combination lock. The class should include the following: an instance variable to represent the combination: this might be a String or an int, but should be something that can hold exactly 6 digits an instance variable representing the state of the lock: true means locked, false means not locked two constructors: a default constructor that produces a random combination, and a constructor that takes an argument to set the combination; both should set the locked variable to true a void mutator method named unlock that takes a possible combination as an argument; if the argument matches the combination, set the locked variable to false a void mutator method named lock that just sets the locked variable to true a toString method that returns a String depending on the state of the lock - either "locked" or "unlocked
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
