COMP200: Practical 5
COMP200: Practical 5
COMP200: Practical 5
This practical aims to develop your understanding of abstract classes, interfaces and inner classes.
1 A Banking Application
You have been tasked with creating a set of classes to implement the banking application described below.
This bank offers two types of bank accounts: traditional and shariah accounts.
All accounts:
• Have an account number, an account holder and a balance
• Accept deposits
• Allow the account holder to transfer an amount of money from one account to another account (held
at the same bank).
• Are able to issue a statement for each bank account at the end of every month. The statement lists
the transactions completed during the month.
• All bank accounts allow withdrawals, provided that the balance never falls below zero for shariah
accounts and R500 for traditional accounts. If there are sufficient funds, the withdrawal proceeds.
Otherwise, the bank cancels the withdrawal.
COMP200 1 2023
Practical Five COMP200 - Practicals 2023
(a) The behaviour of the deductFees and withdrawal methods are different (as described above).
(b) Only traditional accounts earn interest. This class should therefore implement the addInterest
method from InterestBearingAccount that takes in the interest rate as a parameter.
(c) The end of the month fees will be charged by the deductFees method which also resets the
transaction count to zero. deductFees should use withdraw, and addInterest should use deposit.
You must ensure that all your constructors initialise the objects properly!
3. Write an application class to simulate the monthly activity.
The application class must create a set of accounts and run a set of transactions on these accounts
(You will need to create an instance of the inner class Transctions to do so. The text file accounts.txt
contains a list of accounts to create and the text file transact.txt contains all transactions for a
particular month. See the text files for the format.
The test class must have an ArrayList or array of type BankAccount to store bank account objects. You
then read transactions from the file and run each one on the appropriate accounts using appropriate
methods. Then calculate the fees payable and interest rates due. Lastly, print out (to the screen) a
statement for each account.
4. Extension: Allow the user to interact with the program with javax.swing.JOptionPane INSTEAD of
the console (Scanner for inputs and System.out.println for outputs). Hint: You will need both message
and input dialogs to complete this task!
COMP200 2 2023
Practical Five COMP200 - Practicals 2023
If you did not edit the textfile, the statements for each of the accounts would be similar to the ffg:
S t a t e m e n t f o r a c c o u n t n u m b e r 11111
Account holder : Mohammed Osman
B a l a n c e : R 5354 ,23
2 transactions t h i s month :
2 / 3 / 2023 : w i t h d r a w a l of : R 550 ,00
5 / 3 / 2023 : d e p o s i t of : R 300 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 22222
Account holder : Hugh Murrel
B a l a n c e : R 19489 ,19
2 transactions t h i s month :
1 / 3 / 2023 : w i t h d r a w a l of : R 1000 ,00
2 / 3 / 2023 : t r a n s f e r to : A c c o u n t No .: 88888 a m o u n t of R 750 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 33333
Account holder : Deshendran Moodley
B a l a n c e : R 1475 ,80
1 transactions t h i s month :
3 / 3 / 2023 : w i t h d r a w a l of : R 650 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 44444
Account holder : Amina Randeree
B a l a n c e : R 4239 ,46
1 transactions t h i s month :
4 / 3 / 2023 : t r a n s f e r to : A c c o u n t No .: 77777 a m o u n t of R 350 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 55555
Account holder : Johnny May
B a l a n c e : R 520 ,34
1 transactions t h i s month :
1 / 3 / 2023 : w i t h d r a w a l of : R 500 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 66666
Account holder : Barrie Kelly
B a l a n c e : R 531 ,41
2 transactions t h i s month :
2 / 3 / 2023 : w i t h d r a w a l of : R 550 ,00 [ C A N C E L L E D ]
2 / 3 / 2023 : w i t h d r a w a l of : R 250 ,00 [ C A N C E L L E D ]
S t a t e m e n t f o r a c c o u n t n u m b e r 77777
Account holder : Haroon Bassa
B a l a n c e : R 8435 ,34
1 transactions t h i s month :
4 / 3 / 2023 : t r a n s f e r to : A c c o u n t No .: 33333 a m o u n t of R 150 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 88888
Account holder : Asad Jeewa
B a l a n c e : R 1339 ,20
2 transactions t h i s month :
1 / 3 / 2023 : w i t h d r a w a l of : R 200 ,00
5 / 3 / 2023 : t r a n s f e r to : A c c o u n t No .: 88888 a m o u n t of R 150 ,00
S t a t e m e n t f o r a c c o u n t n u m b e r 99999
Account holder : Luke Vorster
B a l a n c e : R 403 ,20
1 transactions t h i s month :
2 / 3 / 2023 : d e p o s i t of : R 300 ,00
COMP200 3 2023