Boston Python Workshop 3/Tuesday OO lesson/banking.py: Difference between revisions
Content added Content deleted
(Created page with 'class Bank: def logIn(self, username, password): return True class User: def __init__(self, theUsername, thePassword): self.username = theUser…') |
imported>Jazztpt No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
class Bank: |
<code>class Bank: |
||
def logIn(self, username, password): |
def logIn(self, username, password): |
||
Line 25: | Line 25: | ||
self.balance = self.balance - amount |
self.balance = self.balance - amount |
||
print "Account just withdrew %d bucks; new balance is: %d" % (amount, self.balance) |
print "Account just withdrew %d bucks; new balance is: %d" % (amount, self.balance) |
||
</code> |
Latest revision as of 16:33, 12 July 2011
class Bank:
def logIn(self, username, password):
return True
class User:
def __init__(self, theUsername, thePassword):
self.username = theUsername
self.password = thePassword
class Account:
def __init__(self, user):
self.balance = 0
self.user = user
def addMoney(self, amount):
self.balance = self.balance + amount
print "Account just added %d bucks; new balance is: %d" % (amount, self.balance)
def withdrawMoney(self, amount):
self.balance = self.balance - amount
print "Account just withdrew %d bucks; new balance is: %d" % (amount, self.balance)