Skip to content

Karan-Rastogi/BankingSystem_OOPs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🏦 Banking System (OOPs Project in Java)

A console-based banking system built using Object-Oriented Programming (OOP) principles in Java.
This project simulates basic banking operations such as creating accounts, depositing money, withdrawing money, viewing balance, and viewing transaction history β€” with proper exception handling and clean separation of concerns.


πŸš€ Features

  • Create a new bank account
  • Deposit money
  • Withdraw money (with rules)
  • View account balance
  • View transaction history
  • Robust exception handling
  • Uses cents instead of floating-point values for money accuracy

🧠 OOP Concepts Used

  • Encapsulation

    • Account data (balance, account number) is private and accessed via methods.
  • Abstraction

    • Business rules are handled by the service layer.
  • Separation of Concerns

    • model β†’ domain objects
    • service β†’ business logic
    • Main β†’ user interaction
  • Exception Handling

    • Custom and built-in runtime exceptions are used for rule violations.

πŸ“‚ Project Structure

com.bank com.bank β”œβ”€β”€ Main.java

β”œβ”€β”€ exception

β”‚ β”œβ”€β”€ AccountNotFoundException.java

β”‚ β”œβ”€β”€ InsufficientBalanceException.java

β”‚ └── InvalidAmountException.java

β”œβ”€β”€ model

β”‚ β”œβ”€β”€ Account.java

β”‚ └── Transaction.java

└── service

| └── BankService.java


⚠️ Business Rules Implemented

  • Deposit amount must be positive
  • Withdraw amount must be:
    • Positive
    • Less than the maximum withdraw limit
    • Leave at least minimum balance in the account
  • Account must exist for any operation

Violations of these rules throw runtime exceptions.


❗ Exception Handling Design

  • Service Layer

    • Throws exceptions when rules are violated
    • Does not print messages
  • Main Class

    • Catches exceptions
    • Displays user-friendly messages

Example:

try {
    service.deposit(accNo, amount);
    System.out.println("Deposit successful!");
} catch (RuntimeException e) {
    System.out.println(e.getMessage());
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages