Skip to content

BotlhaleOa/SecureBank

Repository files navigation

SecureBank

A console-based bank account management system written in modern C++ (C++17). It supports multiple account types, fund transfers, transaction history, and persistent storage between sessions — built to demonstrate object-oriented design, not just a single-file script.

Features

  • Multiple account typesSavingsAccount (enforces a minimum balance) and CheckingAccount (allows a configurable overdraft), both derived from an abstract Account base class.
  • Core banking operations — open an account, deposit, withdraw, and transfer funds between accounts.
  • Transaction history — every operation is logged with a timestamp and the resulting balance, viewable per account.
  • Custom exception hierarchyInsufficientFundsException, InvalidAmountException, and AccountNotFoundException give precise, catchable error handling instead of generic error codes.
  • Data persistence — accounts and their transaction history are saved to disk on exit and reloaded automatically on the next run.
  • Input validation — the console menu safely re-prompts on invalid input instead of crashing or looping.

Architecture

SecureBank/
├── include/
│   ├── Account.h            # Abstract base class
│   ├── SavingsAccount.h      # Minimum-balance account
│   ├── CheckingAccount.h     # Overdraft-enabled account
│   ├── Transaction.h         # Single ledger entry
│   ├── Bank.h                 # Owns and manages all accounts
│   └── Exceptions.h          # Custom exception types
├── src/
│   ├── Account.cpp
│   ├── SavingsAccount.cpp
│   ├── CheckingAccount.cpp
│   ├── Transaction.cpp
│   ├── Bank.cpp
│   └── main.cpp               # Console menu / entry point
├── CMakeLists.txt
├── SecureBank.sln              # Visual Studio solution
├── SecureBank.vcxproj
└── SecureBank.vcxproj.filters

Design decisions worth noting:

  • Account is abstract (withdraw() and getAccountType() are pure virtual) because withdrawal rules genuinely differ between account types — a savings account can't go below its minimum balance, while a checking account can dip into its overdraft limit. This is a textbook case for polymorphism rather than a chain of if statements checking account type.
  • Bank uses std::vector<std::unique_ptr<Account>> for ownership, so accounts are automatically cleaned up and can't be accidentally copied or aliased.
  • Transfers withdraw from the source account before depositing into the destination, so a failed withdrawal (insufficient funds) aborts the whole transfer cleanly — no partial state.

Building

Option 1: CMake (Windows, macOS, Linux)

mkdir build && cd build
cmake ..
cmake --build .
./SecureBank        # or SecureBank.exe on Windows

Option 2: Visual Studio

Open SecureBank.sln in Visual Studio 2022, select a configuration (Debug/Release, x64/x86), and press F5 or Ctrl+F5.

Sample usage

========== SecureBank ==========
1. Open a savings account
2. Open a checking account
3. Deposit
4. Withdraw
5. Transfer between accounts
6. View account summary
7. View transaction history
8. View all accounts
9. Save and exit
=================================
Enter your choice: 1
Enter account holder name: Botlhale Nthite
Enter opening deposit: R1000
Savings account created. Account number: 1001

Possible future improvements

  • PIN/password authentication per account
  • Interest accrual over time for savings accounts (the interest rate is already modeled but not yet applied automatically)
  • Unit tests (e.g. with Catch2 or GoogleTest) for the withdrawal/transfer edge cases
  • A simple GUI or web front end

Author

Botlhale Nthite — github.com/BotlhaleOa

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors