/*
 * Word.java
 *
 * Created on November 10, 2005, 3:10 PM
 *
 */

/**
 *
 * @author Bill Kraynek
 */
public class Word implements Comparable<Word>{
    private String word;
    private int count;
    
    /** Creates a new instance of Word */
    public Word(String word) {
        this.word = word;
        count = 1;
    }
    public String getWord() {
        return word;
    }
    public int getCount() {
        return count;
    }
    public void incrementCount() {
        count++;
    }
    public boolean equals(Object rhs) {
        if( rhs == null ) return false;
        if( !this.getClass().equals(rhs.getClass()) ) return false;
        return this.getWord().equals(((Word)rhs).getWord());
    }
    public int hashCode() {
        return word.hashCode();
    }
    public String toString() {
        return word + " appeared " + count + " time" + (count==1?"":"s");
    }
    public int compareTo(Word rhs) {
        return this.getWord().compareTo(rhs.getWord());
    }
}// end Word

