9 - Reference Counting and a Linked List
due December 4th
assignment will give you practice writing constructors and destructors,
overloaded operator functions,
and implementing a linked list. You will also employ a
technique called reference counting.
goal of the assignment is to track the inventory of various "items".
You will read and process a transaction
(partially displayed below). The transaction file contains 5
types of transactions.
You are to store a count of the items in
a sorted linked list.
- The transaction file contains slightly over 100 random
transaction entries. The five transaction type entries are:
<item number> - add the item to the inventory, or
increase the count for that item
<item number> - subtract the item from the inventory, or
decrease the count for that item
inventory - print the contents of the linked list (in
sorted order) as shown below
transactions (add, subtract, or print may be misspelled) -
print an error message, including the line number in the file
lines - skip over these (but count the lines)
- There are only 10 unique item numbers.
- You must write your own linked list. You may not
use any STL containers.
- The linked list
must be maintained in sorted order by the
- The linked list node must contain the item number and a
count of the number of that item that are added to the inventory.
- If the item is not in the inventory, then
that node must be removed.
must print out the contents of the linked list when a "print inventory"
transaction record appears. See sample output below.
must write at least 2 classes, a "node" class and a "linked list"
class. Both classes must contain constructors and the "linked
list" class must have a destructor.
- You must include at least two overloaded operators as
- The print function of your "linked list" class must be
implemented as an overloaded insertion operator function.
This is the first 32 records of the input file.
Get input file here
Here is some partial output from the program.
transaction: ad in line #9
Bad transaction: subttact in line #13
Bad transaction: prlnt in line #51
This output shows the contents of the linked list after the first print
inventory transaction (plus a few more lines).