|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--DigitalLock
A lock with a three digit combination. This class is derived from the example in Nino and Hosch, chapter 6. These locks are created in the open state. They can be closed, then reopened by providing the right combination of digits. Also, these locks are welded closed after certain errors. Once a lock is welded, no entry will match the combination and the lock stays closed forever.
| Constructor Summary | |
DigitalLock(int theCombination)
Create a lock with the given three digit combination. |
|
| Method Summary | |
void |
close()
Close this lock. |
void |
enter(int digit)
Enter a digit of the combination. |
boolean |
isOpen()
Get the state of the lock. |
void |
resetCombination(int oldC,
int newC)
Reset the combination of this lock. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DigitalLock(int theCombination)
theCombination - the combination value for this lock.
The digit in the 100's position is considered to be the first
digit of the combination, the 10's position is the second digit,
and the units position is the third digit.
This value must be >=0 and <=999. If it is not, then
the lock is welded closed.| Method Detail |
public void enter(int digit)
digit - the single digit entry. Must be a single decimal digit 0-9.public boolean isOpen()
public void close()
public void resetCombination(int oldC,
int newC)
oldC - the existing combinationnewC - the new combination
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||