package username.textanalysis; /** * A simple way to represent word/frequency pairs. * * @author Samuel A. Rebelsky * @version 1.0 of April 2006 */ class WordFrequency { // +------------------+------------------------------------- // | Design Decisions | // +------------------+ /* (1) This class is not public. It is intended primarily for other classes to use. (2) Since the class is not public, we do not provide setters and getters for the fields. */ // +--------+----------------------------------------------- // | Fields | // +--------+ /** The word. */ String word; /** Its frequency. */ double frequency; // +--------------+----------------------------------------- // | Constructors | // +--------------+ public WordFrequency(String _word, double _freq) { this.word = _word; this.frequency = _freq; } // WordFrequency(String, double) // +------------------+------------------------------------- // | Standard Methods | // +------------------+ public String toString() { return this.word + " [" + Math.round(this.frequency*1000)/1000.0 + "]"; // return this.word + " [" + Math.round(this.frequency*1000) + "]"; } // toString() } // class WordFrequency