特定のターン数 (例: 10) 内で数字を推測する必要がある単純なゲームを作成します。しかし、それは非常に簡単に打ち負かすことができます。私が助けを必要としているのは、ゲームがどのくらい続いているかを追跡する方法です.
これは私がこれまでに考えたものです(ゲームロジックを除く)が、機能していないようです
Random ranNum = new Random();
double input; // The input
long startTime; // The time the game started
long curTime; // The time the game ended
double randNum = ranNum.nextInt(100);
while (curTime > 1000){
curTime = System.currentTimeMillis();
input = TextIO.getlnDouble();
if (input = Math.abs(randNum)){
System.out.println("You got the correct answer");
} // End if statement
else {
System.out.println("You did not have the correct answer");
System.out.println("The number was" + randNum + ".");
} // End else statement
} // End while statement