This repository contains a Python solution for a classic OOP challenge. The goal was to create a functional bank account class that manages balances while preventing overdrawn transactions.
- Encapsulation: Manages account data using class attributes (
owner,balance). - Deposit Logic: Increases the balance based on user input.
- Secure Withdrawals: Includes a logical check to ensure withdrawals do not exceed the available balance.
- String Representation: Uses the
__str__method for clean, readable object printing.
Github Url -https://github.com/RohanSMetkar/Bank_Account_Problem_For_Withdraw_And_Deposit/new/main?filename=README.md
The Account class is initialized with an owner's name and an optional starting balance.
- Deposit: Adds funds and confirms the transaction.
- Withdrawal: Checks if
balance >= withdrawal_amount. If true, funds are deducted; otherwise, an error message is displayed.
# Instantiate the class
acct = Account("Rsm", 10000)
# Make a deposit
acct.deposit(500)
# Attempt a withdrawal
acct.withdrawl(2000)
# Check account status
print(acct)