Class Word

java.lang.Object
textprocessing.Word
All Implemented Interfaces:
Comparable<Word>
Direct Known Subclasses:
BasicWord, Bigram, VocabularyEntry

public abstract class Word extends Object implements Comparable<Word>
Abstract class that defines the basis of word objects
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Word(String word)
    Constructor for the Word class that stores the inherited word
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    addLocation(long location)
    Adds a new location to an existing Word.
    abstract boolean
    Returns true if the passed in Object is equal to this Object The method is made abstract so all inheriting classes must implement their own equals() method and are not allowed to inherit the Object class equals()
    abstract String
    Returns a String representation of the Word.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Field Details

    • word

      protected final String word
  • Constructor Details

    • Word

      public Word(String word)
      Constructor for the Word class that stores the inherited word
      Parameters:
      word - the String to store
  • Method Details

    • addLocation

      public abstract void addLocation(long location)
      Adds a new location to an existing Word. If the location is invalid an appropriate exception should be thrown
      Parameters:
      location - a location of the word
    • toString

      public abstract String toString()
      Returns a String representation of the Word. The method is made abstract so all inheriting classes must implement their own toString() method and are not allowed to inherit the Object class toString()
      Overrides:
      toString in class Object
      Returns:
      a String representation of the Word
    • equals

      public abstract boolean equals(Object o)
      Returns true if the passed in Object is equal to this Object The method is made abstract so all inheriting classes must implement their own equals() method and are not allowed to inherit the Object class equals()
      Overrides:
      equals in class Object
      Parameters:
      o - the Object to compare to this
      Returns:
      true if this and o are equal, false otherwise