+ 2

Battleship game

I am using java. how would you compare the rows and columns of one ship to another in the battleship game? Also, how would you put the values of each ship in the battleship board with scanner?

7th Jun 2020, 8:13 PM
Rush Shah
Rush Shah - avatar
2 odpowiedzi
+ 2
Hello Rush Shah I would fill a matrix (2d array) using a nested for loop and each ship gets a letter (or a number). For example: xxxAAA BxCCxx Bxxxxxx BxxDDD With another nested for loop you can check if there is an empty field or a ship.
7th Jun 2020, 8:32 PM
Denise Roßberg
Denise Roßberg - avatar