CSCI 162 - Lecture 9 - Class Programming Activity

Topics Covered

  1. WordCount - Develop a WordCount ADT that counts the number of times given words are found in a file.
    Your class should adhere to the following specification:

    1. Use a generic Node class - Use the Node class to hold the unique words of a file read. The head of this list should be a private instance variable of the WordCount class.

    2. Include a readFile(String filename) method - Make this method public. This method will read the specified file and load each word of the file into the Node linked list by calling the insert method described below.

    3. Include an insert(String word) method - This method should insert a new word string into the list, maintaining the list in a case-insensitive but alphabetical order, and only add a new node if the word is not already in the list. If the word is in the list, update the Node for the word, incrementing an internal occurrence counter that keeps track of how many times the word has occurred.

    4. Include a printReport() method - This method will print out all the unique words found in the file along with their number of occurences.

Instructor's Solution