package piglatin;

/**
 * A Pig Latin generator.
 * @author Kevin Ji <kevin.ji@outlook.com>
 */
public class PigLatin {
    private static final char[] VOWELS = {'a', 'e', 'i', 'o', 'u'};
    
    public static String pigLatinWord(String word) {
        char firstLetter = word.charAt(0);
        boolean startsWithVowel = isVowel(firstLetter);
        String newWord;
        
        if (startsWithVowel) {
            newWord = word + "way";
        } else {
            newWord = word.substring(1) + firstLetter + "ay";
        }
        
        return newWord;
    }
    
    private static boolean isVowel(char letter) {
        for (char vowel : VOWELS) {
            if (letter == vowel) {
                return true;
            }
        }
        
        return false;
    }
    
    public static void main(String[] args) {
        System.out.println(pigLatinWord("happy"));
        System.out.println(pigLatinWord("egg"));
    }
}

@@ -182,24 +182,428 @@
  'u'%7D;%0A    %0A
+    public static String pigLatinPhrase(String phrase) %7B%0A        String%5B%5D words = phrase.split(%22 %22);%0A        %0A        for (int index = 0; index %3C words.length; index++) %7B%0A            String word = words%5Bindex%5D;%0A            String newWord = pigLatinWord(word);%0A            words%5Bindex%5D = newWord;%0A        %7D%0A        %0A        String newPhrase = String.join(%22 %22, words);%0A        return newPhrase;%0A    %7D%0A    %0A
     public s
@@ -1282,24 +1282,35 @@
 d(%22happy%22));
+ // appyhay
 %0A        Sys
@@ -1346,16 +1346,149 @@
 %22egg%22));
+ // eggway%0A        %0A        System.out.println(pigLatinPhrase(%22we are one big family%22));%0A        // eway areway oneway igbay amilyfay
 %0A    %7D%0A%7D

Add pigLatinPhrase