[Tutor] Program Questions

Lloyd Kvam pythonTutor at venix.com
Thu Jul 15 18:58:31 CEST 2004


How does it fail???
What's wrong?

It's easier to help if we can see the error message, the traceback, and
the relevant pieces of program code.



On Thu, 2004-07-15 at 12:45, mandy bowen wrote:
> 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/
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582



More information about the Tutor mailing list