【发布时间】:2013-11-18 14:54:37
【问题描述】:
如何打印出与单词长度相同的破折号“-”? 我使用了 for 循环,但只有 1 个破折号。
for(int i=0; i<secretWordLen; i++) theOutput = "-";
主要:
public String processInput(String theInput) {
String theOutput = null;
String str1 = new String(words[currentJoke]);
int secretWordLen = str1.length();
if (state == WAITING) {
theOutput = "Connection established.. Want to play a game? 1. (yes/no)";
state = SENTKNOCKKNOCK;
} else if (state == SENTKNOCKKNOCK) {
if (theInput.equalsIgnoreCase("yes")) {
//theOutput = clues[currentJoke];
//theOutput = words[currentJoke];
for(int i=0; i<secretWordLen; i++) theOutput = "-";
state = SENTCLUE;
【问题讨论】: