The 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.

The goal of the assignment is to track the inventory of various "items". You will read and process a transaction file (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:

- add <item number> - add the item to the inventory, or increase the count for that item
- subtract <item number> - subtract the item from the inventory, or decrease the count for that item
- print inventory - print the contents of the linked list (in sorted order) as shown below
- misspelled transactions (add, subtract, or print may be misspelled) - print an error message, including the line number in the file
- blank 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 item number. You are not to use a sort function or perform any sorting. Rather, you are to insert each new node in the location so that the linked list is in ascending order by the item number.
- 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.
- You must print out the contents of the linked list when a "print inventory" transaction record appears. See sample output below.
- You 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 member functions.
- The print function of your "linked list" class must be implemented as an overloaded insertion operator function.

add 9171 add 6503 add 0042 add 0042 add 4467 add 6965 ad 8469 add 8469 subtract 4467 subttact 9171 add 6335 add 6503 add 8469 subtract 6503 add 4467 subtract 0042 subtract 8469 add 6335 subtract 6503 add 1480 subtract 8469 add 1480 add 9171 add 1480 subtract 6335 print inventory subtract 9171 subtract 6335 ... |

Get input file here

Output

Bad
transaction: ad in line #9 Bad transaction: subttact in line #13 Item Quantity 0042 1 1480 3 4467 1 6335 1 6965 1 9171 2 Bad transaction: prlnt in line #51 Item Quantity 0042 1 1480 4 4467 2 5726 1 ... |

This output shows the contents of the linked list after the first print inventory transaction (plus a few more lines).