-
while loop help
hi , i created the game battleship but im supposed to end it after the 17th hit 5 hits for ship A 4 for ship B 3 for ship P 3 for ship D and 2 for ship S. What i did was to create a while loop
while i< 17
//my board is here
if (gameBoard.guessPosition(row, column)== true) {
i++;
}
but i realized that if i do that then if the user hits the same ship 17 times the game ends too. I dont know how to make it end after all of the ships have been hit. Any help will be appreciated. Thanks
-
An array of booleans set to true when that ship part has been hit, and a counter to keep track of how many times a value actually changes.