public void humanPlay()
{
if (player1.equalsIgnoreCase("human"))
System.out.println("It is player 1's turn.");
else
System.out.println("It is player 2's turn.");
System.out.println("Player 1 score: " + player1Score);
System.out.print("Player 2 score: " + player2Score);
String eitherOr;
do {
eitherOr= input.nextLine();
humanRoll();
} while (eitherOr.isEmpty());
if (!eitherOr.isEmpty())
humanHold();
}
This is the whole method, The only thing i am trying to fix is this.
String eitherOr;
do {
eitherOr= input.nextLine();
humanRoll();
} while (eitherOr.isEmpty());
It has to accept input multiple times, so each time input is needed to determine what happens, which is why i like the Do While loop, but since it initializes at least once per time, i get an extra roll than needed.
I have tried to do it this way, and various variations of this way:
String eitherOr = input.nextLine();
while(eitherOr.isEmpty());
humanRoll();
This does not work because it does not ask for the input over again. If i try to put the input.nextline(); into the while loop, it says "eitherOr" is not initialized, and even if i initialize it when i enter input, the command line stays blank, so it does nothing with my input.