Please forgive me if I write anything that is irrelevant or wrong regarding my question, since this is actually my first time asking a question here in this website, also, I've only just recently started in Java programming, so please spare me for terminologies and concepts that I can't fully grasp.
So we were tasked to create a basic Text Twist game, one of our objectives was to create a timer that will terminate the current level once it is finished, however, we also need to ask the player for answers while the timer is running.
So me and my group decided to limit the player's tries to 30 and that we'll allow the player to answer for 300 seconds (five minutes).
If one of the above requisites has been fulfilled, then the current level will terminate.
So we used the FOR loop for this case, our code is down below. Please note that all the variables that we used below have been properly initialized in the beginning of the program and that the code below is just a small part of our lengthy code.
By the way, the code below is just a shortened (VERY SHORTENED) version of the loop statement. I just pasted it down there to give you guys a preview on how we did the program.
for (tries=1; tries<=30; tries++)
{
System.out.println();
System.out.println("====================");
System.out.println("Again, the twist is: " + twistlaptop);
System.out.println();
System.out.println("You have found " + guesslaptop + " words.");
System.out.println("Try #" + tries + ".");
System.out.println();
System.out.println("Current score: " + disp.format(score));
System.out.println();
System.out.print("Enter your answer: ");
guess=input.next();
guess=guess.toLowerCase();
System.out.println();
}
We used the word "LAPTOP," for the source word in the first level. So all that is left for us to do, is just the timer. Keep in mind that the code above needs to be running at the same time as the timer, and when one of them (30 tries are done or 300 seconds have passed) finishes, level one terminates and level two starts.
I am very willing to paste the whole code here, however the code contains of 2,277 lines including unnecessary comments in the program, I'll have to delete irrelevant comments if you guys ask me for it.
Again, I'll put emphasis on the part where the player can answer at the same time as the timer is counting down.