你好我的同行!JAVA:文字遊戲查詢
我到目前爲止這樣的代碼:
public class Levels {
int cLevel;
public void newGame() {
boolean newGame = true;
if (newGame) {
cLevel = 1;
List<String> list = new ArrayList<String>();
try {
BufferedReader bf = new BufferedReader(new FileReader(
"src/WordGuess/ReadFile/LevelFiles/Level_" + cLevel
+ ".txt"));
String cLine;
while ((cLine = bf.readLine()) != null) {
list.add(cLine);
}
String words[] = new String[list.size()];
words = list.toArray(words);
System.out
.println("These are your help letters so you can beat that level: "
+ words[0]);
for (int i = 1; i < words.length; i++) {
char[] replaceChar = words[i].toCharArray();
for (int x = 0; x < replaceChar.length; x++) {
replaceChar[x] = '*';
}
String replacement = new String(replaceChar);
System.out.println("\f" + replacement);
}
System.out.println("\t Score: " + Score(0) + ";\t Lives: "
+ Lives(5) + ";");
System.out.println("\n Enter Word:");
System.in.read();
} catch (Exception e) {
System.out
.println("Oh! Something went terribly wrong. A team of highly trained and koala-fied koalas have been dispatched to fix the problem. If you dont hear from them please restart this program.");
e.printStackTrace();
}
}
}
private int Lives(int lives) {
int wrongTries = 0;
boolean correctWord;
int counter = 0;
String livesForm[] = new String[lives];
// for (int i = 0; i == lives; i++) {
// livesForm[i] = "♥";
// }
return lives;
}
private int Score(int score) {
return score;
}}
所以我的查詢如下。
我想將生命表現爲心臟符號,並且仍然保持它的整數值用於功能目的。因此,如我的代碼示例5所示,生命由5個心代表,但仍然保持5的int生命值。如我的示例中所示,我還嘗試使用整數值「生命」大小的字符串數組,並嘗試被心所取代。至於我跑代碼沒有任何錯誤顯示,所以我會假設該數組已被填充,但我不知道如何顯示在控制檯中的數組作爲「生活:♥♥♥♥♥」。
我曾嘗試與常規:
System.out.println(livesForm[i]);
但它並沒有顯示任何內容。我不知道我是否已經清楚地構建了我的問題。如果你們中的任何一個能給我一個建議或暗示,我會很高興。感謝您花時間在這個問題上!
我想指出的不是每個人都在這個網站上是一個「傢伙」... – mdewitt
@mdewitt我對任何給您帶來的不便表示歉意,因爲我認爲您的好人給我們帶來了不好的印象。我的意思是絕對好,沒有任何不好的意圖。我想我會以某種方式「打破冰塊」。 – braumer
沒關係:)只是讓你知道 – mdewitt