Hi,
been reading up head first
java. there's a bit about creating a battleship game and i just jumped ahead and tried doing it myself.
so far i managed to create a grid which populates ships denoted by 'x' in 3 cells. i'm having trouble getting the checks right if it tries to populate it in the same cells.
here is my code. please assist in giving me advice is getting it to work, i'd really appreciate it.
here's a working output for me:
row position: 2
board length marker 2: 6
board length marker 2: 5
board length marker 2: 4
row position: 0
board length marker 2: 6
board length marker 2: 5
board length marker 2: 4
row position: 4
board length marker 2: 6
board length marker 2: 5
board length marker 2: 4
Printing starts here..
x x x - -
- - - - -
x x x - -
- - - - -
x x x - -
non-working output:
row position: 2
board length marker 2: 6
board length marker 2: 5
board length marker 2: 4
row position: 1
board length marker 2: 6
board length marker 2: 5
board length marker 2: 4
row position: 1
col increment: 1
col increment: 2
col increment: 3
board length marker 2: 3
As you can see as soon as its the same row it fails to work. it also fails to print the grid : /
Thanks in advance.