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 convenient 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.

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 a syllable. For example:

·         "simplicity" contains 4 syllables.

·         "group" contains 1 syllable.

·         "keeping" contains 2 syllables.

·         "aye" contains 1 syllable.

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

·         "syllable" contains 2 syllables.

·         "able" contains 1 syllable.

·         "are" contains 1 syllable.

·         "Rae" contains 1 syllable.

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

·         "testing123" counts as 2 syllables.

·         "What?" counts as 1 syllable.

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:

·         "pqr132" counts as 1 syllable.

·         "X=227-314" counts as 1 syllable.

Returns:

the number of syllables in this 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.