[Tutor] Program Questions
mandy bowen
leomandy at hotmail.com
Thu Jul 15 18:45:05 CEST 2004
Can someone tell me what I am doing wrong?? I cannot get this program to
run and I want to add exception-handling, GUI, text processing, etc., but
none of these will work unless the base program runs and I cannot figure out
where I have made the mistake... Please Help!
Program as follows:
import time
class Account:
def _init_(self, initial):
self.balance = initial
self.strdeposit = []
self.strwithdraw = []
def deposit(self, amt):
self.balance = self.balance + amt
self.strdeposit.append(str(time.strftime(%d %b %Y)) + $ + str(amt))
def withdraw(self, amt):
self.balance = self.balance amt
self.strwithdraw.append(str(time.strftime(%d %b %Y)) + $ + str(amt))
def trans(self):
for i in range(len(self.strdeposit)):
print self.strdeposit[i] + +
for i in range(len(self.strwithdraw)):
print self.strwithdraw[i] +
def getbalance(self):
# print self.balance
print str(time.strftime(%d %b %Y) + $ + str(self.balance))
class Menu:
def DisplayMenu(self):
print --------------------------------
print - Main Menu -
print --------------------------------
print 1. Make A Deposit
print 2. Make A Withdrawal
print 3. View Transactions
print 4. View Account Balance
print 5. Exit
def MenuOption(self, option, Account):
if option == 1:
print \n
Account.deposit(input(Deposit amount: $))
print \n
print TRANSACTION COMPLETED
print \n
elif option == 2:
print \n
Account.withdraw(input(Withdraw amount: $))
print \n
print TRANSACTION COMPLETED
print \n
elif option == 3:
print \n
Account.trans()
print \n
print QUERY COMPLETED
print \n
elif option == 4:
print \n
Account.getbalance()
print \n
print QUERY COMPLETED
print \n
elif option == 5:
exit()
a = Account(1000.00)
menu = Menu()
menu.DisplayMenu()
print \n
menuitem = input(Enter Your Selection --> )
while menuitem < 5:
menu.MenuOption(menuitem, a)
menu.DisplayMenu()
print \n
menuitem = input(Enter Your Selection --> )
Any help I can get would be greatly appreciated!
Thanks!
Mandy
_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page FREE
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/
More information about the Tutor
mailing list