SA-3, due Sep 27
This short assignment should be pretty easy. It will give you a little practice in using inheritance, which you'll be using a lot in PS-3.
Assignment
My bank is the Bailey Bros. Building and Loan of Bedford Falls. (Their office is near the sign that reads "You are now in Bedford Falls.") Bailey Bros. offers a special kind of savings account: an ATM savings account. It's like a savings account, except that all transactions occur via ATMs. Because Bailey Bros. is a small operation, they don't own any ATMs. So all transactions occur via what are known in the banking industry as "foreign ATMs." The owner of an ATM typically charges for each transaction, and Bailey Bros. passes the costs of some of these transactions on to the account holder.In particular, because Bailey Bros. is always pleased to get deposits (after all, you never know when there will be a run on the bank), they waive the ATM fee for deposits. But they pass on the $1.50 charge for each ATM savings account withdrawal to the customer. They allow each ATM savings account holder two free ATM withdrawals per month, so the $1.50 per-withdrawal charge kicks in for all withdrawals starting from the third one of the month.
Your task is to create a class ATMSavingsAccount
that
represents a Bailey Bros. ATM savings account. It should support the
following methods:
- A constructor that takes a rate. It sets the initial balance to $0.00.
- A constructor that takes a rate and an initial balance.
- A
deposit
method. - A
withdraw
method. - A
getBalance
method. - A
transfer
method. (From the point of view of withdrawal charges, a transfer counts as a withdrawal from the account being transferred from.) - A
toString
method. - An
addPeriodicInterest
method. Along with adding the interest, this method also performs the deductions for having more than two withdrawals in the period. (First add interest, then deduct the charges.) Of course, it also resets the number of withdrawals in the period back to 0.
Your ATMSavingsAccount
class should be a subclass of one
of the classes from this lecture. I'll leave it to
you to decide which class to make its direct superclass. Note
that some of the above methods can be simply inherited from the
superclass, and some you will have to write yourself.
Needless to say, you may not modify any of the classes
BankAccount
, CheckingAccount
,
SavingsAccount
, or TimeDepositAccount
.
You should also modify the AccountTest
class to test your
ATMSavingsAccount
class. Hint: It's particularly easy to
just change Harry's checking account to an ATM savings account.
Hand in
Hand in the ATMSavingsAccount
and
AccountTest
classes, along with output from a test run,
electronically on Blackboard.