⭐ Introduction
A Banking System is one of the best real-world examples to understand Object-Oriented Programming (OOP) concepts.
In this mini project, we will design a simple banking system using C# that supports:
- Creating bank accounts
- Depositing money
- Withdrawing money
- Checking balance
- Using OOP principles correctly
This project uses clean class design, proper encapsulation, and inheritance-ready architecture.
🎯 Project Objectives
By the end of this project, you will understand how to:
✔ Design real-world classes
✔ Protect sensitive data using encapsulation
✔ Use constructors and properties
✔ Apply inheritance for account types
✔ Build reusable and scalable code
🧱 Project Class Design
We will create the following classes:
1️⃣ BankAccount (Base class)
2️⃣ SavingsAccount (Derived class)
3️⃣ CurrentAccount (Derived class – optional)
4️⃣ Bank (Manager / Controller class)
🏦 1️⃣ BankAccount Class (Base Class)
✔ Responsibilities:
- Store account details
- Protect balance
- Handle deposit & withdrawal
🧑💻 Code:
public class BankAccount
{
private double balance; // Encapsulation
public int AccountNumber { get; }
public string AccountHolder { get; set; }
public double Balance
{
get { return balance; }
}
public BankAccount(int accNo, string holder, double initialBalance)
{
AccountNumber = accNo;
AccountHolder = holder;
balance = initialBalance;
}
public virtual void Deposit(double amount)
{
if (amount > 0)
{
balance += amount;
Console.WriteLine($"Deposited: {amount}");
}
else
{
Console.WriteLine("Invalid deposit amount.");
}
}
public virtual void Withdraw(double amount)
{
if (amount > 0 && amount <= balance)
{
balance -= amount;
Console.WriteLine($"Withdrawn: {amount}");
}
else
{
Console.WriteLine("Invalid or insufficient balance.");
}
}
public void ShowBalance()
{
Console.WriteLine($"Current Balance: {balance}");
}
}
💰 2️⃣ SavingsAccount Class (Inheritance + Polymorphism)
✔ Adds interest functionality
✔ Overrides withdrawal behavior
public class SavingsAccount : BankAccount
{
public double InterestRate { get; set; }
public SavingsAccount(int accNo, string holder, double balance, double rate)
: base(accNo, holder, balance)
{
InterestRate = rate;
}
public void AddInterest()
{
double interest = Balance * InterestRate / 100;
Deposit(interest);
Console.WriteLine("Interest added.");
}
public override void Withdraw(double amount)
{
if (Balance - amount >= 1000) // minimum balance rule
base.Withdraw(amount);
else
Console.WriteLine("Minimum balance of 1000 must be maintained.");
}
}
✔ Uses inheritance
✔ Uses method overriding
✔ Demonstrates business rules
🧾 3️⃣ CurrentAccount Class (Optional Extension)
public class CurrentAccount : BankAccount
{
public double OverdraftLimit { get; set; }
public CurrentAccount(int accNo, string holder, double balance, double overdraft)
: base(accNo, holder, balance)
{
OverdraftLimit = overdraft;
}
public override void Withdraw(double amount)
{
if (amount <= Balance + OverdraftLimit)
base.Withdraw(amount);
else
Console.WriteLine("Overdraft limit exceeded.");
}
}
🏛️ 4️⃣ Bank Class (Account Manager)
✔ Manages multiple accounts
✔ Acts as controller layer
public class Bank
{
private List<BankAccount> accounts = new List<BankAccount>();
public void AddAccount(BankAccount account)
{
accounts.Add(account);
Console.WriteLine("Account added successfully.");
}
public BankAccount FindAccount(int accNo)
{
return accounts.FirstOrDefault(a => a.AccountNumber == accNo);
}
public void DisplayAllAccounts()
{
foreach (var acc in accounts)
{
Console.WriteLine($"Account: {acc.AccountNumber}, Holder: {acc.AccountHolder}, Balance: {acc.Balance}");
}
}
}
🖥️ Step 2 — Main Program (Execution)
class Program
{
static void Main()
{
Bank bank = new Bank();
SavingsAccount sa = new SavingsAccount(101, "Amit", 5000, 5);
bank.AddAccount(sa);
sa.Deposit(2000);
sa.Withdraw(3000);
sa.AddInterest();
sa.ShowBalance();
Console.ReadLine();
}
}
🧠 OOP Concepts Used in This Project
| Concept | Usage |
|---|---|
| Class & Object | BankAccount, SavingsAccount |
| Encapsulation | Private balance + property |
| Inheritance | SavingsAccount : BankAccount |
| Polymorphism | Withdraw() override |
| Constructor | Account initialization |
| Collections | List<BankAccount> |
🌈 Real-World Mapping
| Real World | Code |
|---|---|
| Bank Account | BankAccount class |
| Savings Account | SavingsAccount |
| Deposit | Deposit() |
| Withdraw | Withdraw() |
| Bank | Bank class |
🚀 Optional Enhancements (For Advanced Practice)
1️⃣ Interface IAccount
2️⃣ Transaction History
3️⃣ File / Database storage
4️⃣ Menu-driven console UI
5️⃣ Exception handling
6️⃣ Interest scheduler
7️⃣ Unit tests
📝 Mini Exercise
Try adding:
- TransferMoney(fromAcc, toAcc, amount)
- Account closing feature
- Monthly interest automation
🔍 FAQs
Q1: Is this a real-world OOP project?
Yes, banking systems are classic OOP examples.
Q2: Which OOP concepts are covered?
Encapsulation, inheritance, polymorphism, constructors, collections.
Q3: Can this be converted to Web API later?
Yes, this design is API-ready.
🎉 Conclusion
This Banking System mini project demonstrates how real business logic is modeled using OOP in C#.
It prepares you for:
✔ Enterprise application design
✔ Interviews
✔ API and database projects
✔ Clean architecture