File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 22Simple BankAccount class demonstrating core OOP concepts.
33
44Reference:
5- https://docs.python.org/3/tutorial/classes.html
5+ Invariant-preserving bank account state model.
6+
7+ This module implements a minimal transactional data model whose computational
8+ value is the enforcement of account invariants during constant-time state
9+ transitions: account identifiers must be present, balances may not start
10+ negative, deposits must be positive, and withdrawals may not overdraw the
11+ account.
612"""
713
814
915class BankAccount :
1016 """
11- Basic bank account model with encapsulated account number and balance.
17+ Stateful account abstraction with validated balance updates .
1218
19+ The class is intentionally small, but its purpose is not to serve as a
20+ generic OOP tutorial. It provides a compact example of how to model a
21+ mutable record while preserving correctness constraints across operations,
22+ with each transaction executing in O(1) time.
1323 >>> account = BankAccount("ACC-1001", initial_balance=100.0)
1424 >>> account.balance
1525 100.0
You can’t perform that action at this time.
0 commit comments