[Tutor] account class
Steven Gilmore
Steven Gilmore" <srGilmore@sprintmail.com
Sat, 22 Jul 2000 19:42:25 -0400
I'm trying to write a class that models a bank account. I've started simple
with a deposit method, a print statement method, and balance property (I
haven't gotten to the interest yet). Maybe I'm missing something though I
can't figure out what. Since you guys/gals have been helpful so far maybe
somebody could shed so light.
Tell me it I have got this right
(exaggerated comments)
class Account:
#when a new instance of this class is created, this line is called #
def __init__(self):
self.balance = 0.0
#this sets the balance property to the value of the argument#
def deposit(self,balance):
self.balance= balance
#prints a statement #
def statement():
print balance
>>> import account
>>> a = account.Account()
>>> a.deposit(1.0)
>>> a.statement()
Traceback (innermost last):
File "<interactive input>", line 0, in ?
TypeError: no arguments expected
hope that's enough info for ya to help me :)
thanks in advance
Steven Gilmore