A local bank offers various types of accounts, some of which accrue interest and others that do not.
For simplicity's sake we will have interest compounded once at
the end of each month.
You will implement bank account classes that will track instances of the various types of accounts through various events.
The code we provide creates and works with bank accounts over multiple months, performing the following actions.
By now you should have fetched starter code from the shared Git repository whose URL your instructor or SLI gave you, and started on the implementation described below.
Now that you have had some experience designing your own classes,
we want you to implement a solution using our design. You will
finish the implementation of the parent abstract
class. You will also implement three account subclasses:
A text file with a skeleton implementation of
class is provided as an example.
Currency class is
included so you don't have to think about calculating with dollars
As you saw from the problem solving session, all account types
have a lot in common. One commonality is that all accounts must
report the amount of interest paid. We will designate that method
to be abstract because we don't know how each account
will calculate the interest - we'll leave that to the implementing
class to specify.
We are using an exception class
to be thrown when a withdrawal on a debit account would cause its
balance to go below zero or a charge on a credit account would
cause the balance to exceed the credit limit. Here is the syntax for
throwing a simple exception in Java.
throw new InsufficientFunds();
All interest rates are constants in the various classes. We
assume that a statement period is a month, thus the value of
You are provided with three test programs that will test your implementation. If you look at the comments at the end of each test's source file, you will see the expected output. For formatting issues, see the Handy Tips section below.
These classes and their relationships can be visualized in the following UML diagram. Notice that we are showing you a bit of the recommended state for each of the classes. There is more that you must add in the form of private fields. In the diagram, generated by IntelliJ IDEA, the opened lock means public, the key means protected, and if there were any locked locks, those would designate private features. Note that the superclass has some protected methods that keep the class from having any protected fields. This practice improves encapsulation.
The black-on-orange f's represent fields. The
tiny pin on the upper left means
and the diamond on the bottom left means
Take a moment to familiarize yourself with the program design by
reviewing the javadocs. You will
note that in that documentation some of the classes are in the
bank package and others are in the
package. Those in the
latter package contains the classes you are to implement. Look at
the documentation to find out more details of how things are to
One hard-to-notice item that may be handy is the constant
ZERO in the
is $500.00. The constant
They does not show up in the generated documentation.
To compute the monthly interest rate, divide the appropriate annual
interest rate constant by
Formatted printing can be achieved with the
the class to which
See the sample output in the test files' comments for formatting.
Currency objects format themselves, so all that is left
is the spacing of the strings. However, we will not be deducting grade
points if the output does not match exactly with respect to spacing.
Zip together all your java source files into a file called lab04.zip. This file must be in zip format.
Submit your file to the MyCourses dropbox for this assignment.
Push your work to your github repository as well.
The grade breakdown for this lab is as follows: