注册 登录
编程论坛 新人交流区

java 问题求助

patricknb 发布于 2007-10-04 00:46, 345 次点击

我是新人,刚刚开始学java。现在在做 hangman game
我中文表达的可能不太好,我现在在滑铁卢大学学computer science,一些java 中文的术语不太清楚。。。希望大家能明白我说的意思就行。~

想问一下高手,
假设我输入了一个字母 String n = a ;
System.out.println ("The letter "+ n + " occurs at the following locations in the word: " + comp.whereIsLetterInWord(n));
String theWordis = comp.whereIsLetterInWord(n);
System.out.println ("The word is: " + theWordis );

输出:

Enter a letter: a
The letter 'a' occurs at the following locations in the word: _____a__
The word is: _____a__

这个是没有问题的,但是如果我再输入一个r的话
输出:
Enter a letter: r
The letter 'a' occurs at the following locations in the word: __r_____
The word is: __r_____

我如何让我输入r之后显示如下:

Enter a letter: r
The letter 'r' occurs at the following locations in the word: __r_____
The word is: __r__a__

0 回复
1