Class Word

java.lang.Object
  |
  +--Word

public class Word
extends Object

The Word class represents a single word. It provides a method to count the number of syllables in the word as well as a convenience method that determines if a particular character is a vowel.


Constructor Summary
Word(String w)
          Construct a new Word based on the parameter w.
 
Method Summary
 int countSyllables()
          Count and return the number of syllables in this Word.
 String getWord()
          Get the word represented by this Word object.
static boolean isVowel(char ch)
          Determine if ch is a vowel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Word

public Word(String w)
Construct a new Word based on the parameter w.

Parameters:
w - the String which constitutes the new word.
Method Detail

countSyllables

public int countSyllables()
Count and return the number of syllables in this Word. For simplicity, each group of adjacent vowels is counted as one syllable. For example:

There is one exception to the above rule. A single 'e' appearing at the end of a word does not count as a separate syllable. For example:

All non-letter's such as digits and punctuation should be treated as non-vowels. For example:

All words must have at least 1 syllable. So, if by the above calculations a word would have 0 syllables it should be reported to have 1 syllable. For example:

Returns:
the number of syllables in this Word.

getWord

public String getWord()
Get the word represented by this Word object.

Returns:
the word.

isVowel

public static boolean isVowel(char ch)
Determine if ch is a vowel. Vowels are considered to be "AEIOUY" and "aeiouy".

Parameters:
ch - the character to be checked.
Returns:
true if ch is a vowel and false if it is not a vowel.