/*
 * PigLatin.java      Authors: Koffman and Wolz
 * Class that can translate a word to pig Latin
 */
public class PigLatin {

   // Data field
   String word;    // word to be translated

   // Methods
   public PigLatin() {}

   public PigLatin(String wor) {
     word = wor;
   }

   public void setWord(String wor) {
     word = wor;
   }

   // postcondition - returns true if word begins with a vowel
   private boolean firstLetterIsAVowel() {
      String vowels = "aeiouyAEIOUY";
      char first = word.charAt(0);

      // Search for first letter among vowels and
      //   return true if first letter is found
      return vowels.indexOf(first) > -1;
   }


   // postcondition - translates word to pig Latin
   public String translateWord() {
      if (firstLetterIsAVowel()) {
         return word;
      } 
      else {
         return word.substring(1) + word.charAt(0) + "ay";
      }
   }

   public String toString() {
      return word;
   }
}

