Class User

java.lang.Object
  |
  +--User

public class User
extends Object

A User has a unique id and a hidden password. The object is invalid if the given id is already in use or if creating this user would result in more than MAX_USERS in the system.

Author:
Suzanne Menzel

Field Summary
static int MAX_USERS
          Constant representing the maximum number of valid users.
 
Constructor Summary
User(String id, String password)
          Attempts to create a new user with the given id and password.
 
Method Summary
static int getNumUsers()
          Returns the total number of valid users in the system.
 boolean isValid()
          Returns true if and only if this is a valid user, and false otherwise.
 String toString()
          Returns the id associated with this user.
 boolean verifyPassword(String p)
          Returns true if and only if this is a valid user and the given string p matches the password with which this user was created, and false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_USERS

public static final int MAX_USERS
Constant representing the maximum number of valid users.

See Also:
Constant Field Values
Constructor Detail

User

public User(String id,
            String password)
Attempts to create a new user with the given id and password. This attempt fails if the id is already in use or if creating this user would result in more than MAX_USERS in the system.

Method Detail

verifyPassword

public boolean verifyPassword(String p)
Returns true if and only if this is a valid user and the given string p matches the password with which this user was created, and false otherwise.


isValid

public boolean isValid()
Returns true if and only if this is a valid user, and false otherwise.


toString

public String toString()
Returns the id associated with this user.

Overrides:
toString in class Object

getNumUsers

public static int getNumUsers()
Returns the total number of valid users in the system.