Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Book Inventory

Status
Not open for further replies.

ew456

Programmer
May 4, 2002
46
US
Hey, could someone help, or write a program that will:

Read a book title, authorname, date, status of the book from a file. Then read all the info into the computer. Allow users to search for a book and if they dont find it they can inter the information of the new book into the file. Be able to print out all the books witht their information in alphabetical order.

I would really appreciate it. THank you
 
Hi,

What are the options for the Book Status and how are they defined? And will a fixed format file suffice?

William
Software Engineer
ICQ No. 56047340
 
Oops forgot to ask. What sort of interface do you want for this app? Is it a console application or do you want a windows gui?

William
Software Engineer
ICQ No. 56047340
 
its just simple console, no graphics and this is a full outline of what needs to happen:

1. When the book inventory recieves a new book, the inventory must be updated either by adding to the number in stock or by adding a new entry if the book is not currently present in the inventory.
2. When books go out of print (stock level goes below 0) the inventory should delete the book entry.
3. A complete listing of the books in alphabetical order
4. You must be able to type in a book name and get all the info on the book. The info need in the file is:

1. Title (50 Characters Maximum)
2. Authors Last Name
3. Authors First Name
4. Price of the book
5. Pulisher
6. Serial Number
7. Copyright date
8. Quantity on hand
9. Status (1 for an in-print book, or 0 for an out-of-print book

Any other questions just post them here. I thank you very much for helping me. Anything I can do for you I'll try.
 
I am in my first year of C++, so please try to keep it as basic as possible thanks
 
Ah! If you are in your first year of C++ I guess that this is your course work. With that said I'm not prepared do your work for you, otherwise you'll never learn.

However I will be more than willing to provide you with the logic on how to approach this.

Watch this space for another posting.

William
Software Engineer
ICQ No. 56047340
 
Ok, first things first. Start by creating a structure to replicate a row in the datafile.

struct INVENTORY
{
INVERNTORY() { memset(this, 0, sizeof(INVENTORY)) ; } ;
char Title[51] ;
char Forename[33] ;
char Surname[33] ;
double Price ;
...
} ;

Then create a list manager (LM) class to store the results in. I've already posted some code in the forum (if you can't find it let me know). As a result of this the following assumes that you are using this code as the basis for your LM.

Once you have written / modified your LM you then open the file and read in a row at a time, inserting the rows into the LM.

Using the methods of the LM you will be able to search for books using Author, ISBN, etc. (Assuming you write the methods.) Overloading the << operator will allow you to print the results to screen or file.

Adding a new book to the list simply requires the user to enter the informtion and then calling the Add method of the LM, again overloading the >> will help you here.

Sorry Prof., but I don't quite see the logic in deleting a book from the list when it goes out of stock, since in theory new stock could arrive at anytime! Anyway, since it's a requirement simply call the Remove method of the LM with the appropriate index.

Now, so that your changes persist you'll need to implement a Dump or Write method for your LM. This would simply iterate over the list items and write them to disk, overwriting the existing datafile.

This of course may be a long process depending on the size of your inventory, but there are ways to get round this, but I'll leave that as an exercise for you.

The only real issue here is the printing of an ordered list. If the file is in alphabetical order then no problems, but if it's not....

In my opinion the best approach would be to order the list at the time of insertion into the LM, by modifying the Add() method. You could do it later once the list was loaded but that may not be practical.

If you need any further assistance then please ask, well be more than willing to help.

FYI I tested the list manager code with 18+Mb of data and 1M+ rows, it took 6secs.

HTH
William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top