Homework 10
Due Thurs, Jan 27, 18:00
Exercise 1: (5 points)
Add exception-handling code to your UserAccount class (homework 6):
- If you don't already have one, add a constructor that takes a
loginID and password as
parameters
- Add an equals method that takes an Object as a parameter
- Write your own exception class UserAccountException.java
and
throw it in the UserAccount class in the following situations:
- if the password parameter in the constructor is too short
- if setPassword is called with the wrong current password or an
invalid new password
- if logIn is called with the wrong password
Use UserAccountTest.java
to verify that exceptions are
thrown correctly.
Exercise 2: (5 points)
Add exception-handling code to your LexUnit class (SelfTest 7):
- The addSynonym and addOrthForm methods should throw a
LexUnitException (write this yourself) if the parameter is null or the
empty string
- Any methods within the LexUnit class that call addSynonym or
addOrthForm should pass any thrown exceptions on to the caller (that
is: no methods in the LexUnit class should catch an exception)
Write a junit test class LexUnitTest.java
to verify that exceptions are thrown correctly.
Submit the following files to
Anne (javaiscl (at googlemail.com)):
UserAccount.java
UserAccountException.java
LexUnit.java
LexUnitTest.java