-1

StackOverflow に関する他の do while の問題を調べましたが、問題の解決策が見つかりませんでした。外部で変数を初期化してdo{内部で使用しているのですが、変数が一定値に達するとwhileメソッドが飛び出しません。

ここに私が持っているものがあります:

int aiShotHit = 0;
int shotHit = 0;

do{
  showBoard(board);
  bAi.showAi(ai);
  shoot(shoot,ships);
  bAi.aiHit(aiShoot);
  attempts++;

  if(hit(shoot,ships)){
    hint(shoot,ships,aiShips,attempts);
    shotHit++;
    System.out.println("\nShips Left on the Board: " + shotHit);
  }                
  else
    hint(shoot,ships,aiShips,attempts);

  changeboard(shoot,ships,board);


  if(bAi.aiHit(aiShoot,aiShips)){
    hint(shoot,ships,aiShips,attempts);
    aiShotHit++;
  }                
  else
    System.out.print("");

  bAi.changeAi(aiShoot,aiShips,ai);

}while(shotHit !=3 || aiShotHit !=3);

if (shotHit == 3){
  System.out.println("\n\n\nBattleship Java game finished! You Beat the Computer");

} 
System.out.print("You lost! The Ai beat you");
4

1 に答える 1