Homework 6

Due Thurs, Dec 2, 18:00


Exercise 1: (7 points)

Write a class definition to simulate a user account with a password (UML diagram below).  The basic functionality that we want is to be able to allow the user to log in and out, and to reset the password.  To log in, the correct password must be given (parameter of the logIn method).  If an attempt is made to log in with the wrong password, the user will not get logged in.  To reset the password, the current password must be given as well as the new password (if the current password is incorrect, the password will not be reset - it remains the same). Passwords must have at least 8 characters.


UserAccount

-  loginID : String
-  password : String
-  loggedIn : boolean


+ setLoginID(String newLoginID) : void
+ getLoginID() : String
+ isLoggedIn() : boolean
isPassword(String aPassword) : boolean
isValidPassword(String aPassword) : boolean
+ setPassword(String curPassword, String newPassword) : void
+ logIn(String aPassword) : void
+ logOut() : void
+ equals(UserAccount otherUser) : boolean
+ toString() : String




Exercise 2: (2 points)

Use UserAccountTest.java to partially test your class.  When all of the tests pass, add 2 more tests:
  1. test that the setPassword method does not reset the password when both the current password is incorrect and the new password is invalid
  2. test that the equals method returns true even when one user is logged in and the other is logged out

Exercise 3: (1 point)

Open UserAccount.java in drjava.
From the menu select Tools -> Javadoc ->  "Preview Javadoc for Current Document"

In the "Method Summary" section, you should see a list of all of the public method headers (not the private ones, though), including the first sentence of the method description.  Click on the method names to see the full descriptions, parameters, and return values.

Make sure that the documentation is complete and correct for each public method.

You do not need to submit anything for exercise 3.



Submit the following files to Anne (javaiscl (at googlemail.com)):
UserAccount.java
UserAccountTest.java