CSCI 162 - Lecture 9 - Class Programming Activity
Topics Covered
- 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:
- 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.
- 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.
- 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.
- 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
- Source for updated Node.java is here.
- Source for WordCount.java is here.
- Source for WordCountMain.java is here.