Lab 4
Lab 4
Lab 4
Objectives
• Implement an Account class.
• Implement a Bank class.
• Use loops.
• Use arrays.
• Write one of the classes from scratch (no template given as in previous labs)
Overview
A classic application of object-oriented techniques is a bank account. In this lab, you
will implement a simplified model of a bank account and of a bank itself.
A bank Account will track the account number, the owner's name and the current balance.
The only operations allowed (apart from trivial getters) will be withdrawing and depositing
money. A user will not be allowed to make a deposit or withdrawal of a negative or zero value.
Furthermore, they will not be allowed to withdraw more money than they have in the account.
An account, of course, must belong a specific bank; hence you will also implement the Bank
class. A Bank object will keep track of all of the accounts it has; it will also disallow two
accounts with the same account number.
1
• boolean deposit(double amount)
• boolean withdraw(double amount)
In addition, you are provided with a toString() method below that you must not
modify.
Source Code
Bank.java, MainAccount.java and MainBank.java classes are provided with the
lab. More details about these classes are in the instructions below.
3
(Alice, 123, $85.00)