Search code examples
javawhile-loopnested-loops

While loop not executing and I don't know why


I'm creating a loop and for some reason it doesn't execute. It's not an infinate loop

while ((aH <= 0) || (bH <= 0))
{
  // ROUND LOOP START
  System.out.println("============");
  System.out.println("  Round " + round);
  System.out.println("============");


  // A TURN START
  while (endTurn == 1)
  {
   System.out.println("==========================");
   System.out.println("  Commander " + aN + ", GO!");
   System.out.println("==========================");
   endTurn++;

  // A TURN END
  }
  endTurn--;


  // B TURN START
  while (endTurn == 1)
  {
    System.out.println("==========================");
   System.out.println("  Commander " + bN + ", GO!");
   System.out.println("==========================");
   endTurn++;

  // B TURN END
  }
  endTurn--;
  bH -= 10;

  round++;
  // ROUND LOOP END
}

System.out.println("The loop was skipped for some reason");

When I executed the test on the loop, this is what happened.

The loop was skipped for some reason

Currently the loop has no purpose, it will have functions, but I'm currently concerned with it not executing. Does anyone see the problem?


Solution

  • I slapped myself when I realized that I was using the while loop incorrectly. Anyway... not a problem anymore! Thanks anyways!