Class LockBox

java.lang.Object
  extended by LockBox

public class LockBox
extends java.lang.Object

Class that password protects a text message.

Version:
10/14/06
Author:
Dave Reed

Constructor Summary
LockBox(java.lang.String password)
          Constructs a LockBox object.
 
Method Summary
 java.lang.String access(java.lang.String password)
          Accesses the stored message.
 int numberOfAccesses()
          Accessor for the number of valid accesses since the message was set.
 int numberOfFailedAttempts()
          Accessor for the number of failed access attempts since the message was set.
 boolean setMessage(java.lang.String password, java.lang.String message)
          Sets the stored message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockBox

public LockBox(java.lang.String password)
Constructs a LockBox object.

Parameters:
password - the password used to lock/unlock the box
Method Detail

access

public java.lang.String access(java.lang.String password)
Accesses the stored message.

Parameters:
password - the password used to lock/unlock the box
Returns:
the stored message (assuming the password was correct); otherwise, return "INCORRECT PASSWORD"

numberOfAccesses

public int numberOfAccesses()
Accessor for the number of valid accesses since the message was set.

Returns:
the number of valid accesses so far

numberOfFailedAttempts

public int numberOfFailedAttempts()
Accessor for the number of failed access attempts since the message was set.

Returns:
the number of failed access attempts so far

setMessage

public boolean setMessage(java.lang.String password,
                          java.lang.String message)
Sets the stored message.

Parameters:
password - the password used to lock/unlock the box
message - the message to be stored
Returns:
whether the message was actually stored (i.e., the password was correct)