Class WordCount

java.lang.Object
  extended by WordCount

public class WordCount
extends java.lang.Object

This class stores a word and a count representing the number of times the word appears in a document.


Field Summary
private  int count
           
private  java.lang.String theWord
           
 
Constructor Summary
WordCount(java.lang.String theWord)
          Constructor takes as input the word and initializes the count to 0.
 
Method Summary
 int getCount()
          Return the count.
 java.lang.String getWord()
          Return the word.
 void increment()
          The increment method adds one to the count.
 java.lang.String toString()
          Returns a string representation of the object in the form: Word: theWord Count: count
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

theWord

private java.lang.String theWord

count

private int count
Constructor Detail

WordCount

public WordCount(java.lang.String theWord)
Constructor takes as input the word and initializes the count to 0.

Parameters:
theWord -
Method Detail

increment

public void increment()
The increment method adds one to the count.


getWord

public java.lang.String getWord()
Return the word.

Returns:

getCount

public int getCount()
Return the count. Used for testing.

Returns:

toString

public java.lang.String toString()
Returns a string representation of the object in the form: Word: theWord Count: count

Overrides:
toString in class java.lang.Object