$Revision: 1.1 $
In this lab you will implement several classes that make use of inheritance. The specification of the classes and the methods you will implement is in the form of "Javadoc" comments, which describe the meaning and purpose of classes, methods, and variables.
Go to the bottom of the class web page and download cs101-lab9.zip to the Desktop. Start a terminal window and run the command
Start DrJava and open each Java source file in the "cs101-lab9" directory (which will be a subdirectory of the Home directory).
You will implement four classes: BankAccount, SavingsAccount, CheckingAccount, and RetirementAccount. These classes make use of inheritance as follows:
BankAccount is the overall superclass. It represents a bank account with a balance and methods to get the current balance, deposit funds, withdraw funds, and transfer funds. It also includes a monthlyUpdate method that does nothing: it is meant to be overridden by subclasses.
SavingsAccount is a subclass of BankAccount. A SavingsAccount has an interest rate, and its monthlyUpdate method adds earned interest to the balance.
RetirementAccount is a subclass of SavingsAccount. A RetirementAccount has a method depositEmployeeContribution that is like an ordinary deposit, except that the amount deposited is increased by a matching contribution from the employer equal to the amount of the deposit up to a maximum matching contribution amount.
CheckingAccount is a subclass of BankAccount. Its monthlyUpdate method checks to see if the balance is below a minimum balance; if so, a penalty is subtracted from the balance.
You are provided with skeletal versions of the four classes, along with a BankAccountTest class that implements JUnit tests for the classes. Your task is to complete each class so that when you run the JUnit tests, all of the tests pass.
In the initial versions of the classes, each method contains the following statement:
throw new UnsupportedOperationException("not implemented yet");
These statements serve as placeholders indicating that the method is not implemented yet. As you work on implementing the methods, you will remove these statements, replacing them with an actual implementation of each method.
Each class and method is specified with a javadoc comment. These comments outline exactly what you need to do in each method.
You may also use the JUnit test cases as a specification. By looking at the tests, you should get a good sense of how the classes and methods are supposed to work.
Demonstrate to a lab coach or instructor that all of the JUnit test cases pass.
Start a terminal window. Run the following command:
zip -9r cs101-lab9-solution.zip cs101-lab9
You should see something like the following output:
adding: cs101-lab9/ (stored 0%) adding: cs101-lab9/SavingsAccount.class (deflated 32%) adding: cs101-lab9/BankAccount.class (deflated 49%) adding: cs101-lab9/SavingsAccount.java (deflated 54%) adding: cs101-lab9/BankAccountTest.java (deflated 78%) adding: cs101-lab9/CheckingAccount.java (deflated 59%) adding: cs101-lab9/BankAccountTest.class (deflated 52%) adding: cs101-lab9/CheckingAccount.class (deflated 33%) adding: cs101-lab9/RetirementAccount.class (deflated 34%) adding: cs101-lab9/RetirementAccount.java (deflated 65%) adding: cs101-lab9/BankAccount.java (deflated 70%)
Submit cs101-lab9-solution.zip using the CS 101 Submission Website. Make sure you submit cs101-lab9-solution.zip, not cs101-lab9.zip.