C# console-based banking system that demonstrates Object-Oriented Programming (OOP) through Accounts, Transactions (Deposit, Withdraw, Transfer), and rollback aspects.
- Create and store accounts in-memory
- Deposit and Withdraw with validation
- Transfer between accounts (withdraw + deposit)
- Transaction state tracking:
Executed,Success,Reversed - Rollback support for transactions
- Interactive console menu (text UI)
- Encapsulation
- Account state (
Name,Balance) is private and modified only via methodsdeposit()andwithdraw().
- Account state (
- Composition
TranserTransactioncomposes aWithdrawTransactionandDepositTransactionto perform an atomic transfer.
- Abstraction (interfaces suggested)
- Each transaction exposes
Execute(),RollBack(), and read-only flags. - Future improvement: Introduce a common
ITransactioninterface or abstract base class to unify transaction handling.
- Each transaction exposes
- Information Hiding & Invariants
- Balance updates are only allowed via guarded methods that validate amounts and available funds.
- Error Handling as Part of Design
- Transactions guard against double execution and invalid rollback attempts with clear exceptions and flags.
git clone https://github.com/nodogx/Banking-System-Simulator.git
cd Banking-System-Simulator
### 2. Build the Project
Make sure you have the .NET SDK installed (e.g., .NET 7 or .NET 8):
```bash
dotnet builddotnet runYou’ll see:
1. Withdraw
2. Deposit
3. Print Account
4. Transfer
5. Add Account
6. Quit
Enter the number for your action.
-
Add an account
Select option: 5 Enter account name: Alice Enter starting balance: 100 -
Deposit funds
Select option: 2 Enter account name: Alice Enter amount to deposit: 50 -
Withdraw funds
Select option: 1 Enter account name: Alice Enter amount to withdraw: 30 -
Transfer funds
Select option: 4 Enter source account name: Alice Enter destination account name: Bob Enter amount to transfer: 20 -
Print balance
Select option: 3 Enter account name: Alice -
Exit
Select option: 6