-1
初學者在這裏試圖返回註釋方法:使用switch語句高爾夫球場景
public static String comment(int score, int parForHole) {
if (parForHole - score > 4)
return "condor!!!!";
if (parForHole - score == 3)
return "albatross!!!";
if (parForHole - score == 2)
return "eagle!!";
if (parForHole - score == 1)
return "birdie!";
if (parForHole - score == 0)
return "par";
if (parForHole - score == -1)
return "bogey";
if (parForHole - score == -2)
return "double bogey";
if (parForHole - score < -2)
return "triple+ bogey";
return "asdasd"; // Replace by a suitable switch stmt.
}
有沒有類似的方式來做到這一點使用switch語句?我不太熟悉它。 任何幫助表示讚賞謝謝!
突破?真? – dit