我正在尝试将您的句子翻译成拉丁语的程序。下面的代码我到目前为止:猪拉丁语句子转换器
public class PigLatin {
public static void main(String[] args) {
//Enter text in the quotes of System.ot.println(covertToLatin(" "));
System.out.println(covertToLatin("Type your sentence here."));
}
private static String covertToLatin(String string) {
String end = "";
String delims = "\\s+";
String[] words = string.split(delims);
for (int i = 0; i < words.length; i++) {
if(isVowel(words[i].toLowerCase().charAt(0))) {
end += words[i] + "ay";
} else {
end += words[i].substring(1) + words[i].substring(0, 1) + "ay";
}
}
return end;
}
private static boolean isVowel(char c) {
if (c == 'a')
return true;
if (c == 'e')
return true;
if (c == 'i')
return true;
if (c == 'o')
return true;
if (c == 'u')
return true;
return false;
}
}
它翻译“在这里输入你的句子。” to“ypeTayouryayentencesayere.hay”我很难找到一种方法来翻译我的整个句子。你能帮我把整句翻译成拉丁文吗?另外,如果你能找到一种方法让句子在所有大写字母上转换,它也会有所帮助。
对不起,我很困惑你的问题是什么,什么不是你想要的? –
它不工作,只是没有空格?如果我清理你的输出,这是合理的拉丁语:'ypeTay ouryay entencesay ere.hay'。我认为你只需要在单词之间添加空格。 – Ian
它看起来像你的结果几乎是正确的,除了一些缺陷。你应该能够解决这些问题。 – ajb