473,657 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Coding help...very basic

I need some ideas of how to accomplish this task.
I was told that I just need to save the input in a file and make the file
searchable, nothing fancy like tying into SQL or Oracle. THis is a basic
program and help is greatly appreciated:
You've been given an assignment by your supervisor to program a small
application to monitor the current status of the cash account in the
firm's petty cash fund (the amount of cash kept on hand in the office for
incidental purchases). The requirements for the program are to allow
users to input the amount of cash deposited, the amount of cash withdrawn
and to get a report of the balance at any given time. You will need to
also add the date of each deposit and the date of each withdrawal and
provide a date with the balance returned upon a given query. The program
should be able to provide a printed report and support a command line
query.

You are to use the object oriented properties of Python to accomplish this
task.

Jul 18 '05 #1
6 1737
Hi,

people here usually tend not to be too helpful when asked to do an obvious
homework task. So if you really want help, provide some code you've already
written and that has actual problems. Then we're glad to help. But don't
expect others to do your work.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
On Sun, 06 Mar 2005 12:47:27 -0500, "Igorati" <wa***********@ yahoo.com>
declaimed the following in comp.lang.pytho n:
I need some ideas of how to accomplish this task.
I was told that I just need to save the input in a file and make the file
searchable, nothing fancy like tying into SQL or Oracle. THis is a basic
program and help is greatly appreciated:
Searchable by what? Only by your application, or via a text
editor or GREP?

incidental purchases). The requirements for the program are to allow
users to input the amount of cash deposited, the amount of cash withdrawn
and to get a report of the balance at any given time. You will need to
also add the date of each deposit and the date of each withdrawal and
provide a date with the balance returned upon a given query. The program
should be able to provide a printed report and support a command line
query.
Sounds like a check-book register... I'd probably use a simple,
fixed width, record oriented text file with columns of:

date activity amount {optional balance}

For quick current balance retrieval I'd probably use the first
record for the current balance only (file will need "r+" access, fixed
width means you can correctly index through it by just "record # *
width"). You could even store the count of data records in the date
field, as the "current balance" will either be the date/time of the
query, or can be obtained from the last transaction record.

Problem with the "optional balance" field is that, if entries
are made in one order, and the data is subsequently sorted, the running
balance field is out of order...
You are to use the object oriented properties of Python to accomplish this
task.
This sounds like a homework assignment, possibly asking for one
to use pickle to store "deposit" and "withdrawal " objects. I don't think
I'd bother with a "current balance" object, though it does mean having
to scan the entire data set to compute.
-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Jul 18 '05 #3
Thank both for the help. I understand that I should provide code, I am
still trying to understand what to do, I don't want the work done, just
some ideas of where to go, a general layout perhaps. Thank you.

Jul 18 '05 #4
This is just a basic of what I have so far. The time , a class I will need
and the print function.

class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,a mt):
self.balance = self.balance - amt
def getbalance(self ):
return self.balance

import time
time.asctime()

import win32api
source_filename = "log.txt"
win32api.ShellE xecute (
0
"print"
source_filename
None
"."
0)
Jul 18 '05 #5
On Sun, 06 Mar 2005 18:37:34 -0500, "Igorati" <wa***********@ yahoo.com>
declaimed the following in comp.lang.pytho n:
This is just a basic of what I have so far. The time , a class I will need
and the print function.

class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,a mt):
self.balance = self.balance - amt
def getbalance(self ):
return self.balance
Probably too high a level... Recall: your requirements suggest
you need to maintain the date of each deposit/withdrawal. This would
imply that you can't just keep a running total. How else could you
create a report?...

If you want a sort of hierarchy, you could have Transaction (a
base class, has date and amount fields, and maybe identifier of who
performed the transaction, but does not handle debit/credit direction);
Deposit(Transac tion) {inherits from transaction}, which treats the
amount as a positive value; Withdrawal(Tran saction), which treats the
amount as a negative value; Account, which has an account owner, and a
list of Transactions... getBalance() would return the result of summing
the Transactions.

The file processing could be done by recursively pickling an
account object, and all the transactions it contains.
Shifting focus for a moment... One of the starting points in
many OO-related courses is...

Look at your problem description... Find the nouns... These are
candidates for the objects (classes) you need; some may be removed as
irrelevant later.

Look for the verbs... These may indicate the candidates for
object methods.
-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Jul 18 '05 #6
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.

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(sel f,

self.transactio n =
import time
time.asctime()
raw_input("Is this a deposit or withdrawl?")
if withdrawl:
elif
raw_input("Plea se enter amount here.")

class Deposit(Transac tion):
def deposit(self, amt):
self.balance = self.balance + amt
def getbalance(self ):
return self.balance

class Withdrawl(Trasa ction):
def withdrawl(self, amt):
self.balance = self.balance - amt
def getbalance(self ):
return self.balance
import pickle
pickle.dump ((withdrawl), file ('account.pickl e', 'w'))
pickle.dump ((deposit), file ('account.pickl e', 'w'))

print "Your current account total is.", self.balance
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

102
7564
by: RFox | last post by:
I date back to the early days of the web when HTML was limited but very managable, and have always maintained that hand-coding HTML gives you far better control and cleaner HTML markup than any WYSIWYG editor. But all the sites I created and manage are small sites (<50 pages). And I've been out of the loop in terms of what's new in methodology and with the specifications for the past couple of years.
63
3491
by: Papadopoulos Giannis | last post by:
Which do you think is best? 1. a) type* p; b) type *p; 2. a) return (var); b) return(var); c) return var;
144
6842
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this initiative. Typically I find that coding standards are written by some guy in the company who has a way of coding that he likes and then tries to force everybody else to write code the way he likes it, not for any rational reason, but simply for the...
1
1698
by: R Reyes | last post by:
Hello All, I'm always looking for ways to improve my code. Most of the time (whenever I'm working on a project) I write a bunch of functions. Then after the project is finished, I put all the similar functions into their own module/class/page for neatness: -- like a stringsManipulate class which has all string manipulation methods to the project...separated from the whole project into its own library for neatness. -- like a...
3
3343
by: ct-86 | last post by:
http://www.cdbook.cn/book.asp?id=2393 Organizational and Policy Issues 1 0. Don't sweat the small stuff. (Or: Know what not to standardize.) 2 1. Compile cleanly at high warning levels. 4 2. Use an automated build system. 7 3. Use a version control system.
14
2406
by: key9 | last post by:
Hi All On coding , I think I need some basic help about how to write member function . I've readed the FAQ, but I am still confuse about it when coding(reference / pointer /instance) , so I think I need some "template". Sorry for my coding experience in c++
4
6691
by: AzizMandar | last post by:
C++ Event Coding Questions I have done some simple programs in C++ and read a lot of good C++ books (Including The C++ Programing Language, and C++ Primer) I am trying to understand and implement an Event based program and Message system. I have a very basic event engine that I'm feeling works a bit backwards. I'm looking for documents, source code, and books that may help me better understand how to implement this type of code. I am...
2
2667
by: rlemusic | last post by:
Hi everybody, I’m creating a database in Access (I believe it’s 2000) to catalogue items in the archives of a small museum. I’m a total n00b as far as using Access goes, but by looking at some online tutorials and how the museum’s existing collections catalogue is set up in Access, I’ve been able to come up with a basic database that suits the museum’s needs. My biggest issues right now concern Relationships and Codes. I managed to get a...
5
1759
by: Alex | last post by:
Hi, About 5 months ago I changed professions and moved from being a web programmer (ColdFusion mainly) to a Visual Basic.Net app coder, and though this is my first time to do application coding in a decade or more, I'm loving it! It's also my first time to really use OOP, which I'm slowly but surely getting the hang of. Though I've started coding in VB during the day, my home systems are all Linux. If I wanted to start developing...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.