MIAMI DADE COLLEGE
School of Engineering and Technology
COP 2800 - Java Programming
Project 5
Due On: 4/22/2020 by 11:59 PM
Expand
Project 4
as follows:
- Using the
BankAccount
class as a base class, write two derived classes called
SavingsAccount
and
CheckingAccount.
- Add a new private field
name
of type String to the
BankAccount
class.
- Add accessor and mutator methods for the
name
field.
- A
SavingsAccount
object, in addition to the attributes of a
BankAccount
object, should have a
monthlyInterest
variable and a method, which adds interest to the account. Assume you are adding the interest accumulated in a month.
//monthlyInterest += (accountBalance * (annualInterestRate / 12))
//accountBalance += monthlyInterest
public void addInterest() {
//code goes here
};
- The
CheckingAccount
class, in addition to the variables of a
BankAccount
class, should have an
overdraftLimit
variable (default to $50). Ensure that you override methods of the
BankAccount
class as necessary in both derived classes.
Create a
Bank
class, which contains an
ArrayList
of
BankAccount
objects called
bankAccounts.
BankAccounts in the array could be instances of the
BankAccount
class, the
SavingsAccount
class, or the
CheckingAccount
class.
Write an
update
method in the
Bank
class. It iterates through each account, updating it in the following ways:
Savings accounts get interest added (via the
addInterest
method)
Checking accounts get a letter sent (System.out.println) if they are in overdraft. (Hint: use
instanceof
operator)
- The
Bank
class requires methods for
openAccount
and
closeAccount.
openAccount()
should ask the user for:
- his/her name (just first name, no last name)
- what type of bank account (s)he wishes to open. Options are
Regular
Account (BankAccount
object),
Savings
(SavingsAccount
object) or
Checking
(CheckingAccount
object). Create an object of the appropriate type and add it to
bankAccounts. Display the account Id after this operation.
- Initial Balance (minimum $100). Display a message if the user tries to open an account with less than $100 deposit (make sure account does not get created).
closeAccount()
should ask the user for his/her name and the account Id and then delete from
bankAccounts
the account that matches both the
name
and
accountId. If they have a balance print a message indicating that a check with a balance will be mailed to them (indicate amount).
- Test all your classes in the
TestBankAccount
class. Send all output to the console. Use a
Scanner
object to get user responses and
System.out.println
to print to the console.
Additional Hints:
Note that the balance of an account may only be modified through the deposit (double) and withdraw (double) methods.
Changes to the original
BankAccount
class should be minimal.
Make sure to test what you have done after each step.
Make sure to include enough testing in
TestBankAccount
to cover all the functionality implemented.
Submission guidelines:
Send your code files
(BankAccount.java, SavingsAccount.java, CheckingAccount.java, Bank.java and TestBankAccount.java)
as attachments to my email
[email protected], with the subject
Java
Project
5