java.lang.Object | +--Sentence
The Sentence class represents a single sentence. A
sentence is considered to be any String ending in
a '.', ':', ';', '?', or '!'.
Thus, in this context
a Sentence object may contain strings that do not
represent gramatically correct English sentences.
Methods are provided to count the number of words that appear in the sentence, and to get the next word from the sentence.
| Constructor Summary | |
Sentence(String s)
Construct a new Sentence based on the parameter s. |
|
| Method Summary | |
int |
countWords()
Count the number of words in this Sentence. |
Word |
nextWord()
Get the next word in this Sentence. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Sentence(String s)
s - a String representing a sentence.| Method Detail |
public int countWords()
public Word nextWord()
"For example, this is a test.""example" and not "example,".
Similarly, the final word in that sentence will be
"test" and not "test.".