0% found this document useful (0 votes)
59 views3 pages

COMP200: Practical 5

The document describes a banking application assignment that involves creating classes to represent different types of bank accounts. It includes an abstract BankAccount class with subclasses for TraditionalAccount and ShariahAccount. Students must implement methods like transferTo, printStatement, deductFees, withdraw, and addInterest. They also need to write a test application class to simulate account activity by reading transaction data and generating account statements.

Uploaded by

Mhlengi Wiseman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views3 pages

COMP200: Practical 5

The document describes a banking application assignment that involves creating classes to represent different types of bank accounts. It includes an abstract BankAccount class with subclasses for TraditionalAccount and ShariahAccount. Students must implement methods like transferTo, printStatement, deductFees, withdraw, and addInterest. They also need to write a test application class to simulate account activity by reading transaction data and generating account statements.

Uploaded by

Mhlengi Wiseman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical Five COMP200 - Practicals 2023

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

• Provide a method to query the balance.


• Can transfer money from one account to the other.
• Can print the account number and the current balance.
• Pay a service fee.

• 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.

The differences between the two types of accounts are as follows:


• Only traditional accounts earn interest. At the end of every month, the bank adds interest only to
traditional accounts. The interest equals 1.5% of the month-ending balance for the account for that
month. Interest is only paid IF the balance at the end of the month is > R500.

• All traditional accounts pay a fixed monthly fee of R50.


• All shariah accounts pay a monthly service fee which is calculated as follows: The first five transactions
(a transaction for a shariah account is considered to be a deposit or a withdrawal) are free; thereafter,
the holder of the account pays R1.80 per additional transaction. This fee is deducted at the end of 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.

The following is provided:


Download the project archive: Banking.zip Parts of the BankAccount class has already been written. It is
an abstract class with two abstract methods (i.e. methods that must be implemented by sub-classes) viz.
deductFees() and withdraw (double amount). The BankAccount class also has a transactions array. This
is an array of objects from the Transaction INNER class described below. The transferTo method takes
an account and an amount; and transfers the amount from the account object that calls the method to the
account object that is given as an argument. The BankAccount class also has a protected variable called
transactionsCount that is always incremented by a withdrawal, transfer, or deposit. This count indicates
the number of transactions during the month for an account. Study the class for other details.
The Transaction inner class represents a single transaction. Amongst other things, it maintains the date
of the transaction, the time of the transaction and the type of transaction (withdrawal, deposit, or transfer.)
This class only has a toString method to print a transaction’s details.
The InterestBearingAccount interface allows relevant accounts to implement an addInterest() method
to add the interest to the balance at the end of the month. Remember, only a traditional account earns
interest.

COMP200 1 2023
Practical Five COMP200 - Practicals 2023

Complete the banking application:


1. Write the transferTo and printStatement methods in the BankAccount class as described above.
2. Write the TraditionalAccount and ShariahAccount classes to complete the banking application.
TraditionalAccount and ShariahAccount are subclasses of the BankAccount class. They differ from the
BankAccount class in the following ways:

(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

You might also like