Project Architecture & OOP Design
Design a banking application using Java OOP principles — classes for Account, Transaction, Customer, and BankService. Apply inheritance (SavingsAccount extends Account), interfaces (Serializable, Comparable), and encapsulation.
40 min•By Priygop Team•Last updated: Feb 2026
Banking App Architecture
- Account (abstract class) — Properties: accountNumber, balance, owner. Methods: deposit(), withdraw(), getBalance(). Abstract for different account types
- SavingsAccount extends Account — Adds interestRate, calculateInterest(). Overrides withdraw() to enforce minimum balance
- CheckingAccount extends Account — Adds overdraftLimit. Allows negative balance up to the limit
- Transaction class — Records every deposit/withdrawal: amount, type, timestamp, balanceBefore, balanceAfter
- Customer class — Holds customer info (name, ID) and a list of their accounts. One-to-many relationship
- BankService — Business logic: createAccount(), transfer(), getStatement(). Uses Collections for account lookup
Banking App Code
Example
// Account.java (abstract base class)
public abstract class Account {
private final String accountNumber;
private double balance;
private final String ownerName;
private final List<Transaction> transactions = new ArrayList<>();
public Account(String accountNumber, String ownerName, double initialDeposit) {
this.accountNumber = accountNumber;
this.ownerName = ownerName;
this.balance = initialDeposit;
recordTransaction("DEPOSIT", initialDeposit);
}
public void deposit(double amount) {
if (amount <= 0) throw new IllegalArgumentException("Deposit must be positive");
balance += amount;
recordTransaction("DEPOSIT", amount);
}
public abstract void withdraw(double amount) throws InsufficientFundsException;
protected void performWithdraw(double amount) {
balance -= amount;
recordTransaction("WITHDRAW", amount);
}
private void recordTransaction(String type, double amount) {
transactions.add(new Transaction(type, amount, balance));
}
// Getters
public String getAccountNumber() { return accountNumber; }
public double getBalance() { return balance; }
public List<Transaction> getTransactions() { return Collections.unmodifiableList(transactions); }
}
// SavingsAccount.java
public class SavingsAccount extends Account {
private static final double MIN_BALANCE = 100.0;
private final double interestRate;
public SavingsAccount(String accNum, String owner, double deposit, double rate) {
super(accNum, owner, deposit);
this.interestRate = rate;
}
@Override
public void withdraw(double amount) throws InsufficientFundsException {
if (getBalance() - amount < MIN_BALANCE) {
throw new InsufficientFundsException(
"Balance cannot go below $" + MIN_BALANCE
);
}
performWithdraw(amount);
}
public double calculateInterest() {
return getBalance() * interestRate / 100;
}
}