Assignment 9 - Reference Counting and a Linked List

due November 24th

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 Plan

The goal of the assignment is to track a list of various (fruit) "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.  

Details

  1. add <item> - add the item to the inventory, or increase the count for that item 
  2. remove <item> - remove the item from the inventory, or decrease the count for that item.  If the item does not exist, print error message.
  3. print inventory - print the contents of the linked list (in sorted order) as shown below
  4. misspelled transactions (add, remove, or print may be misspelled) - print an error message, including the line number in the file
  5. blank lines - skip over these (but count the lines)

Required Classes

Node class with the following
List class with the following

Program Requirements

Input File

This is the first 32 records of the input file.

add banana
add pear
add orange

add orange
add apple

add peach
add plum
ad plum

remove apple
add watermelon
add pear
add plum
reomve banana
remove pear
add apple
remove orange
remove plum
add watermelon
remove pear
add papaya
remove plum
add papaya
remove potato

add banana
add papaya
remove watermelon
print list
remove banana
remove watermelon
...

Program Output

Here is some partial output from the program.  

Output

Bad transaction: ad in line #10
Bad transaction: reomve in line #16
Unable to remove potato in line #26

Item       Quantity
apple          1
banana         2
orange         1
papaya         3
peach          1
watermelon     1

Bad transaction: prlnt in line #50

Item       Quantity
apple          2
apricot        2
banana         7
orange         1
papaya         4
...

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

Extra Credit (1 point)

You may receive one extra credit point on this assignment if you split your solution into a multiple file application.  You should split the solution into 5 files: 3 source files and 2 header files.  You should have a source file and a header file for each class and a separate source file for main.  Submit your solution as a compressed (zipped) file as an attachment.  The extra credit will only be applied if your assignment is received on time.