Package com.stbasarab.componets
Class SentenceElement
java.lang.Object
com.stbasarab.componets.SentenceElement
Represents an element of a sentence, which can be either a word or a punctuation mark.
This class provides methods to determine the type of element and to compare elements for equality.
-
Constructor Summary
ConstructorsConstructorDescriptionSentenceElement(PunctuationMark punctuationMark) Constructs a SentenceElement object with a punctuation mark.SentenceElement(Word word) Constructs a SentenceElement object with a word. -
Method Summary
-
Constructor Details
-
SentenceElement
Constructs a SentenceElement object with a word.- Parameters:
word- the word that this sentence element represents
-
SentenceElement
Constructs a SentenceElement object with a punctuation mark.- Parameters:
punctuationMark- the punctuation mark that this sentence element represents
-
-
Method Details
-
isWord
public boolean isWord()Checks if this sentence element is a word.- Returns:
- true if this element is a word; false otherwise
-
getWord
Retrieves the word component of this sentence element.- Returns:
- the word, or null if this element is not a word
-
equals
Compares this sentence element to another object for equality. Two sentence elements are considered equal if both are words and are equal, or if both are punctuation marks and are equal. -
hashCode
-