This short assignment will give you a little practice in using inheritance, which you'll be using a lot in upcoming Lab Assignments.
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. (Ask that drunken souse Uncle Billy about things that can go wrong when you're making a deposit. Are you getting these subtle references to the movie It's a Wonderful Life?) 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:
deposit
method.withdraw
method.getBalance
method.transfer
method. (From the point of view of withdrawal charges, a transfer counts as a withdrawal from the account being transferred from.)toString
method.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 Lecture 4. 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 in AccountTest.java to test your ATMSavingsAccount
class. Hint: It's particularly easy to just change Harry's checking account to an ATM savings account.
Submit via Canvas code for the ATMSavingsAccount
and AccountTest
classes, along with output from a test run.