Class WordCount

java.lang.Object
  extended byWordCount

public class WordCount
extends java.lang.Object

A class that counts the occurrances of individual words in different input streams.


Constructor Summary
WordCount(DictionaryADT d)
          Construct a new WordCount Object backed by a DictionaryADT d.
 
Method Summary
 void countWords(java.io.BufferedReader br)
          Count the words from the BufferedReader and add them to the frequency count in the backing DictionaryADT.
 DictionaryADT getWordFrequencyDictionary()
          Retrieves the word/frequency pairs as a Dictionary.
 java.util.List getWordFrequencyList()
          Gets a list of the word/frequency pairs in the dictionary.
static void main(java.lang.String[] args)
          Unit test for the wordcount program
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordCount

public WordCount(DictionaryADT d)
Construct a new WordCount Object backed by a DictionaryADT d. The DictionaryADT must take strings as the key.

Parameters:
d - The DictionaryADT that wordcount uses to count the words.
Method Detail

countWords

public void countWords(java.io.BufferedReader br)
Count the words from the BufferedReader and add them to the frequency count in the backing DictionaryADT.

Parameters:
br - The BufferedReader from which words will be extracted.

getWordFrequencyList

public java.util.List getWordFrequencyList()
Gets a list of the word/frequency pairs in the dictionary.

Returns:
A list of the word/frequency pairs in the dictionary.

getWordFrequencyDictionary

public DictionaryADT getWordFrequencyDictionary()
Retrieves the word/frequency pairs as a Dictionary.

Returns:
A list of the word/frequency pairs in the dictionary.

main

public static void main(java.lang.String[] args)
Unit test for the wordcount program