View Test Results.
package cs221.groupk.common; import java.io.Serializable; /** * User represents a single user to the system. Its methods are only accessable * through those made public in the Disk class. * * <P><P> * <table border="1" cellpadding="3" cellspacing="0" width="100%"> * <tr bgcolor="#CCCCFF" class="TableHeadingColor"> * <td colspan=3><font size="+2"><B>Version History</B></font></td> * </tr> * <tr bgcolor="white" class="TableRowColor"> * <td align="right" valign="top" width="11%"> * <div align="center"><font size="+1">Version No.</font></div> * </td> * <td width="7%"> * <div align="center"><font size="+1">Author</font></div> * </td> * <td width="74%"><font size="+1">Description of changes.</font></td> * </tr> * <tr bgcolor="white" class="TableRowColor"> * <td align="right" valign="top" width="11%"> * <div align="center"><font size="-1">0.1 - 01/12/00</font></div> * </td> * <td width="15%"> * <div align="center"><a href="mailto:pms9@aber.ac.uk">Paul Smith</a></div> * </td> * <td width="74%"> * <div align="left">Initial development</div> * </td> * </tr> * <tr bgcolor="white" class="TableRowColor"> * <td align="right" valign="top" width="11%"> * <div align="center"><font size="-1">0.2 - 05/12/00</font></div> * </td> * <td width="15%"> * <div align="center"><a href="mailto:csm9@aber.ac.uk">Chris Milner</a></div> * </td> * <td width="74%"> * <div align="left">Code / comment spelling corrections.</div> * </td> * </tr> * </table> * <P> * <HR> * <P> * View <A HREF="..\..\..\docs\cs221\groupk\common\User.html">source code</A>.<P> * View <A HREF="..\..\..\docs\cs221\groupk\common\UserModuleTestHarness.html">test harness source code</A>.<P> * View <A HREF="UserModuleTestHarness.html">test harness javadoc</A>.<P> * View <A HREF="..\..\..\docs\cs221\groupk\common\UserModuleTestHarnessResults.html">test results</A>.<P> * <HR> * * @author <A HREF="mailto:pms9@aber.ac.uk">Paul Smith</A> */ public class User implements Serializable { // /////////////////// // // Instance variables. // // /////////////////// // /**userID is the unique String that identifies a user*/ protected String userID; /**fullName is the full name of the employee that the instance of User represents*/ protected String fullName; /**password is the password for this user*/ protected String password; /**admin is true if this user has access to ALL systems and data.*/ protected boolean admin; /**accessTopStation is true if this user has access to the top station*/ protected boolean accessTopStation; /**accessBottomStation is true if this user has access to the bottom station*/ protected boolean accessBottomStation; /** * userActive specifies if the user is still in employment, this allows * User details to be kept after a user has been removed from active use. * If a User is not active then they have no access rights to the system * regardless of their authorisation */ protected boolean userActive; // ///////////// // // Constructors. // // ///////////// // /** * Default Constructor for User. This will set all attributes to unspecifed, * or false. To set the parameters use setDetails, or the individual sets * for each field. * @see #setDetails(String, String, String, boolean, boolean, boolean) */ public User() { userID = "Unspecified"; fullName = "Unspecified"; password = "Unspecified"; admin = false; accessTopStation = false; accessBottomStation = false; } /** * Over-loaded constructor for User. This method accepts all the parameters * required to create a user of any access level.<P><B>Note:</B><BR>The admin * privilage overrides the settings of top and bottom privilage, so if a * <I>User</I> has administration privilages, they also have bottom and top * station privilages. * @param String user ID of this user. * @param String fullname of this user. * @param String password of this user. * @param boolean admin privilage for this user. * @param boolean top station privilage for this user. * @param boolean bottom station privilage for this user. */ public User(String user, String fullName, String password, boolean admin, boolean top, boolean bottom) { super(); this.userID = FuncU.encryptString(user); this.fullName = FuncU.encryptString(fullName); this.password = FuncU.encryptString(password); this.admin = admin; this.accessTopStation = top; this.accessBottomStation = bottom; } /** * setDetails is a convienience method to allow all the details of a <I>User * </I> to be set in a single method.<P><B>Note:</B><BR>The admin privilage * overrides the settings of top and bottom privilage, so if a <I>User</I> * has administration privilages, they also have bottom and top station * privilages. * @param String user ID of this user. * @param String fullname of this user. * @param String password of this user. * @param boolean admin privilage for this user. * @param boolean top station privilage for this user. * @param boolean bottom station privilage for this user. */ public void setDetails(String user, String fullName, String password, boolean admin, boolean top, boolean bottom) { this.userID = FuncU.encryptString(user); this.fullName = FuncU.encryptString(fullName); this.password = FuncU.encryptString(password); this.admin = admin; this.accessTopStation = top; this.accessBottomStation = bottom; } /** * getUserID returns this user Objects ID. * @return the value of userID. */ public String getUserID() { return userID; } /** * setUserID sets this user Object with theUserID. * @param String value to set userID to. */ public void setUserID(String userID) { this.userID = userID; } /** * setFullName sets this user Object with theFullName. * @param String value to set fullName to. */ public void setFullName(String fullName) { this.fullName = fullName; } /** * getFullName gets the full name for this user Object. * @return the value of fullName. */ public String getFullName() { return fullName; } /** * setPassword sets the password of this Object with thePassword. * @param String value to set password to. */ public void setPassword(String password) { this.password = password; } /** * isAdmin returns true if this user can use the admin computer. * @return true if user has administration privialges. */ public boolean isAdmin() { return admin; } /** * setIsAdmin sets if this user Object can use the admin computer. * @param boolean */ public void isAdmin(boolean admin) { this.admin = admin; } /** * topStation returns true is this user can use the top station */ public boolean topStation() { return accessTopStation; } /** * setTopStation sets if this user Object can use the top station. */ public void setTopStation(boolean theTopStation) { accessTopStation = theTopStation; } /** * bottomStation returns true is this user can use the bottom station */ public boolean bottomStation() { return accessBottomStation; } /** * setBottomStation sets if this user Object can use the bottom station. */ public void setBottomStation(boolean theBottomStation) { accessBottomStation = theBottomStation; } /** * setUserActive sets the user specified by userID to the value specified by * userActive. * @param String userID * @param boolean userActive */ public void setUserActive(String userID, boolean userActive) { this.userActive = userActive; } /** * getUserActive returns if the user specifed by userID is active nor not. * @param String userID * @return true if user is active. */ public boolean getUserActive(String userID) { return userActive; } /** * Overrides the <CODE>toString()</CODE> in Object, this method now displays * the users full name, id and access level. * @return String returned containing the text representation of this object. */ public String toString() { String permissions; if(admin) { permissions = "This user has administration privialges to the system."; } else if(accessTopStation && accessBottomStation) { permissions = "This user can access the top and bottom POST computers."; } else if(accessTopStation && !accessBottomStation) { permissions = "This user can access the top POST computer."; } else if(!accessTopStation && accessBottomStation) { permissions = "This user can access the bottom POST computer."; } else { permissions = "This user has no permissions."; } return "Cliff Railway Ticketing System.\n\nUser: " + fullName + "\nUser ID: " + userID + "\n"+ permissions; } public String getPassword() { return password; } }Page automatically generated on: 29/12/00 at: 1:26:45 AM.