我正在從事一項線上Udacity課程的作業,我們被要求開發一種方法來識別名詞的最後一個字母,然後根據字母,出了一個「La」,「el」或「?」 +名詞。需要根據名詞的最後一個字母輸出前綴
完全說明您是完成方法fixNoun在SpanishWord類,以便它返回由前面的名詞:
// "la " if the noun ends in "a",
// "el " if it ends in "o"
// "? " if it ends in some other letter.
我似乎保持編譯時,讓所有的失敗。有人可以幫助我瞭解我做錯了什麼嗎?
public String fixNoun(String noun) {
String determinenet= noun.substring(noun.length() - 1);
if(determinenet.equals("a")) {
System.out.println("la" + " "+noun);
}
else if (determinenet.equals("o")) {
System.out.println("el"+ " "+noun);
}
else {
System.out.println("?"+ " "+noun);
}
return noun;
}
你可以發佈你的整個班級嗎? – Adarsh
你會得到什麼失敗。請在試圖編譯您的課程時發佈您輸出的內容。 – Christian