Simple account program

wes weston wweston at att.net
Thu Mar 17 17:12:06 EST 2005


Igorati wrote:
> Hello all, I am still needing some help on this code, I have gone a bit
> further on it. Thank you for the help. I am trying to understand how to
> make the file searchable and how I am to make the deposit and withdrawl
> interact with the transaction class. 
> I need to just search the file only for the deposits and withdrawls and
> the amount in the account with a time stamp. Thank you for your
> assistance.
> 
> class Account:
>     def __init__(self, initial):
>          self.balance = initial
>     def deposit(self, amt):
>          self.balance = self.balance + amt
>     def withdraw(self, amt):
>          self.balance = self.balance - amt
>     def getbalance(self):
>          return self.balance 
> 
> class Transactoin:
>     def transaction(self,                                                
> 
>                
>         self.transaction = 
>     import time
>     time.asctime()
>     raw_input("Is this a deposit or withdrawl?")
>     if withdrawl:
>     elif     
>     raw_input("Please enter amount here.")
>        
> class Deposit(Transaction):
>     def deposit(self, amt):
>         self.balance = self.balance + amt
>     def getbalance(self):
>         return self.balance
> 
> class Withdrawl(Trasaction):
>     def withdrawl(self, amt):
>         self.balance = self.balance - amt
>     def getbalance(self):
>         return self.balance
> import pickle
> pickle.dump ((withdrawl), file ('account.pickle', 'w'))
> pickle.dump ((deposit), file ('account.pickle', 'w'))
> 
> 
> 
> print "Your current account total is.", self.balance
> 

Igorati,
    Suggestion. Write out what you want to do in
words such that all the things you want to do are
there as unambiguously clear as you can get it.
It will help your thinking on the problem, the
design, and the code; and help anyone trying to
help you.
    Why have transactions not associated with accounts?
All transactions are related to an account; have
a self.TransActList in Account.
    You have "amount" in both Withdrawl and Deposit
both derived from Transaction. If Transactions always
have an amount, why not put amount in the transactions
class? But we don't know.
wes




More information about the Python-list mailing list