Computer Science 122
Assignment 9
Due: December 4, 2003

The final assignment is to rewrite the class in assignment 8 that manages the array.  Change the array to a linked list.  When you read the file into the list, add each product to the end of the list.  Display the list by traveling through the list, and use the code in the linked list example to find a product in the list.

You will also have to change the product class.  You should add a next field to the data in the class and also add getNext and setNext methods.  You will need both when reading in the data and when finding a product in the list.

The following code may be used to find a product in the list.  Note how it differs from the code used when you were searching through an array.

private Product findId (String keyId)
{
      Product tempNode = listHead;
      while ((tempNode != null) && !keyId.equals (tempNode.getId ()))
           tempNode = tempNode.getNext ();
      if (tempNode == null) return null;
      else return tempNode;
 } // findId

You may refer to the Linked List Example that is on my website for additional help.