Case Study - Banking System
Case Study - Banking System
Main.java
The Main class should be a menu-driven program with the following options:
• Create a new customer
• Open an account
• Deposit money into an account
• Withdraw money from an account
• Transfer money between accounts
• Check account balance
• View transaction history
• Calculate interest
• Repay loan
Account Creation
A customer can open multiple accounts, each with a unique account number. When opening an account, they specify
the account type (Savings, Current, or Loan), the initial deposit with each account having an expected minimum
deposit, and the account holder’s details.
Transactions
• Deposit: A customer can deposit money into their account.
• Withdraw: A customer can withdraw money from their account if they have sufficient funds.
• Transfer: A customer can transfer money from one account to another. Both accounts must belong to the
same customer.
• Loan Repayment: For loan accounts, a customer can repay their outstanding loan balance.
Interest Calculation
For Savings Accounts, interest is calculated monthly and added to the balance. For Loan Accounts, interest accrues
based on the remaining balance. Current Accounts do not accrue interest but can have overdraft facilities.
Transaction Log
Each transaction (deposit, withdrawal, transfer) is recorded in a transaction log with the following details:
• Transaction ID
• Account Number
• Transaction Type (Deposit, Withdrawal, Transfer)
• Amount
• Date and Time
Class Details
Bank.java
The Bank class should have the following fields:
• String bankName: Name of the bank.
• ArrayList<Customer> customers: A list of the bank’s customers.
• ArrayList<Account> accounts: A list of all accounts in the bank.
Methods:
• void addCustomer(Customer c): Adds a new customer to the bank.
• void openAccount(Customer c, Account a): Opens an account for a customer.
• Account findAccountByNumber(String accountNumber): Finds an account by its number.
• void transferFunds(String fromAccountNumber, String toAccountNumber, double amount): Transfers
money between two accounts.
• void calculateMonthlyInterest(): Calculates and applies interest for all savings and loan accounts.
Customer.java
The Customer class should have the following fields:
• String customerID: A unique ID for each customer.
• String name: The customer’s name.
• String address: The customer’s address.
• ArrayList<Account> accounts: A list of accounts held by the customer.
Methods:
• Customer(String customerID, String name, String address): Constructor.
• void openAccount(Account a): Adds an account to the customer’s account list.
• Account getAccount(String accountNumber): Finds and returns an account by its number.
Account.java
The Account class should be abstract and should have the following fields:
• String accountNumber: A unique number for each account.
• double balance: The current balance in the account.
• Customer accountHolder: The owner of the account.
Methods:
• Account(String accountNumber, Customer accountHolder, double initialDeposit): Constructor.
• void deposit(double amount): Deposits money into the account.
• void withdraw(double amount): Withdraws money from the account if sufficient balance is available.
• abstract void applyInterest(): Applies interest to the account.
• abstract void logTransaction(String type, double amount): Logs a transaction (deposit, withdrawal,
transfer).
SavingsAccount.java
The SavingsAccount class should extend Account and should have an additional field:
• double interestRate: The interest rate for the account.
Methods:
• void applyInterest(): Calculates and applies interest to the balance.
• void logTransaction(String type, double amount): Logs savings account transactions.
CurrentAccount.java
The CurrentAccount class should extend Account and should have an additional field:
• double overdraftLimit: The overdraft limit for the account.
Methods:
• void withdraw(double amount): Allows overdraft withdrawals if within the limit.
• void logTransaction(String type, double amount): Logs current account transactions.
LoanAccount.java
The LoanAccount class should extend Account and should have the following fields:
• double loanAmount: The total loan amount.
• double interestRate: The interest rate on the loan.
Methods:
• void applyInterest(): Calculates and adds interest to the outstanding loan balance.
• void repayLoan(double amount): Repays part of the loan balance.
• void logTransaction(String type, double amount): Logs loan repayment transactions.
Transaction.java
The Transaction class should have the following fields:
• String transactionID: A unique ID for each transaction.
• String accountNumber: The account associated with the transaction.
• String transactionType: The type of transaction (Deposit, Withdrawal, Transfer).
• double amount: The transaction amount.
• Date date: The date and time of the transaction.
Methods:
• Transaction(String transactionID, String accountNumber, String transactionType, double amount, Date
date): Constructor.
Interface Details
IBank.java
• void addCustomer(Customer c): Adds a new customer.
• void openAccount(Customer c, Account a): Opens a new account.
• Account findAccountByNumber(String accountNumber): Finds an account by its number.
• void calculateMonthlyInterest(): Applies interest for all savings and loan accounts.
IAccount.java
• void deposit(double amount): Deposits money into the account.
• void withdraw(double amount): Withdraws money from the account.
• void applyInterest(): Applies interest to the account.
Additional Complexity:
• Exception Handling: Ensure that the system handles invalid operations such as withdrawing more than the
available balance, exceeding overdraft limits, not satisfying minimum deposits on account creation, and
loan overpayments.
• Inheritance and Polymorphism: Accounts of different types should share common behaviors but implement
specific behaviors (such as interest calculation) differently.
• Audit and Security: Add a transaction log and write a file that stores all actions performed on each account
for auditing purposes.