package jr.eecs1022.piglatin;

import java.util.StringTokenizer;

public class PigLatinTranslator
{
    private String english;
    private String pig;

    public PigLatinTranslator()
    {
        this.setEnglish("");
    }

    public PigLatinTranslator(String text)
    {
        this.setEnglish(text);
    }

    public String getEnglish()
    {
        return this.english;
    }

    public void setEnglish(String text)
    {
        this.english = text.toLowerCase();
        this.translate();
    }

    public String getPig()
    {
        return this.pig;
    }

    // Translate the state to PigLatin
    public void translate()
    {
        StringTokenizer st = new StringTokenizer(this.english);
        String result = "";
        while (st.hasMoreTokens())
        {
            String word = st.nextToken();
            String pig = this.translateWord(word);
            if (result.length() == 0)
            {
                result = pig;
            }
            else
            {
                result = result + " " + pig;
            }
        }
        this.pig = result;
    }

    // Translate the given word to PigLatin
    // and return the translation
    private String translateWord(String word)
    {
        // replace with correct code
        String result = word;

        return result;
    }
}
