Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Simulation for a banking system with various account types and transactions.

a) Define a class Account, has account number and balance as class-members. Account
class must have following methods
a.1) Deposit: Deposit method accept amount as parameter and add amount in balance
field.
a.2) Withdraw: Withdraw method accept amount as a parameter and deduct the amount
from balance field. Proper exception handling must be in place to make sure
customer account balance must not be in negative.
a.3) getBalance : method returns the account balance.

b) Define SavingsAccount class, extend Account class and must have interestRate as
class-member. SavingsAccount must have following methods.
b.1)SavingsAccount constructor must accept account number and interest rate as
parameter.
b.2) calculateInterest : method must return the balance multiply by interest rate.

c) Define CheckingAccount class, extend Account class and must have overdraftLimit
as class-member. CheckingAccount must have following methods.
c.1)CheckingAccount constructor must accept account number and overdraftLimit as
parameter.

d) Define a class Transaction has sourceAccount (of type Account class),


targetAccount (of type Account class) and amount as class-member. Transaction class
must have following methods
d.1) Transaction constructor must accept sourceAccount number, targetAccount number
and amount to be deducted.
d.2) Define execute method which should deduct amount from sourceAccount and
deposit in targetAccount. All check and balances must be placed to handle the
exception.

e) Define TransferTransaction class, extend Transaction class. TransferTransaction


must have following methods.
e.1) Override base class execute method and deduct 5 rs as transaction fee from
sourceAccount account as well keep base class functionality intact.

f) Define TransactionManager class must have list of Transaction as class-member.


TransactionManager must have following methods.
f.1) addTransaction : method must accept the Transaction object and add into list.
f.2) executeTransactions: execute all the transactions.

g) main method must create object of SavingsAccount and CheckingAccount account.


Use TransferTransaction and TransactionManager classes to transfer the money from
SavingsAccount object to CheckingAccount object.

You might also like