Created
February 6, 2012 16:41
-
-
Save jimmykurian/1753188 to your computer and use it in GitHub Desktop.
A BankAccount program with classes, written in Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BankAccount.py - Jimmy Kurian | |
class BankAccount(object): | |
def __init__(self, initial_balance=0): | |
self.balance = initial_balance | |
def deposit(self, amount): | |
self.balance += amount | |
def withdraw(self, amount): | |
self.balance -= amount | |
def overdrawn(self): | |
return self.balance < 0 | |
my_account = BankAccount(15) | |
my_account.withdraw(5) | |
print my_account.balance |
there is no link between object and balance used here! I didn't get how this program is working.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a simple perfect code but what about creating a subclass which inherits properties of class BankAccount with the name MinimumBalance?