【发布时间】:2012-10-30 21:35:44
【问题描述】:
我正在完成我的 com 课上的一项作业,该作业要求我创建一个命运之轮游戏。我目前正在研究getDisplayedPhrase 方法,我将对此进行解释。所以对于这个程序,我有一个随机短语,例如"this is a question, thanks for helping!"
我想把这句话改成"**** ** * ********, ****** *** *******!"
在他们猜到之前,这句话应该是这样的。如您所见,我试图只更改字母,所以我创建了一个
private static final String alpha ="abcdefghijklmnopqrstuvwxyz"
避免任何标点符号。 这是我目前所拥有的:
public String getDisplayedPhrase() {
for (int i = 0; i<secretPhrase.length(); i++){
I don't know what to put here and what method to use???
I'm thinking of using charAt() or indexOf()
}
return displayedPhrase;
}
【问题讨论】:
-
与其说我不知道,不如跳起来尝试使用 charAt() 和 indexOf() 然后卡住。