基本上我需要循環這個。我創建了一個遊戲,您可以在runescape中回答關於魚的問題,並且我希望它能像說'再去一次'那樣循環。我會怎麼做呢?我應該如何循環這個程序?
import java.util.Scanner;
public class GameDriver
{
public static void main(String a[])
{
Game g = new Game();
Scanner s = new Scanner(System.in);
String buf = null;
for(int i = 0; i < 4; i++)
{
System.out.print(g.askQuestion());
buf = s.nextLine();
if(g.confirm(buf))
System.out.println("You're Right!");
else
System.out.println("You're Wrong...");
}
System.out.println("You got a " + g.getScore());
}
}
@ jake-wilks運行這是原樣並讓我們知道結果。 – Rajesh
工作完美謝謝!!!! –
@ jake-wilks您可以請投票/標記爲解決方案嗎? [接受答案] stackoverflow.com/help/accepted-answer; [投票] stackoverflow.com/help/why-vote – Rajesh