|
|
|
@ -55,7 +55,7 @@ public class Battleship{ |
|
|
|
int rot = 0; |
|
|
|
int[] stationary = cur_ship.getStart().clone(); |
|
|
|
while ((rot < 4) && !placed) { |
|
|
|
// ensures ship doesn't intect with any that were previously placed |
|
|
|
// ensures ship doesn't intersect with any that were previously placed |
|
|
|
for (int j = 0; j < i; j++){ |
|
|
|
intersects = cur_ship.isIntersecting(ships[j]); |
|
|
|
if (intersects){ |
|
|
|
@ -78,8 +78,9 @@ public class Battleship{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// we done, place those puppys on for real. |
|
|
|
// we done, place those puppies on for real. |
|
|
|
for (int i = 0; i < 5; i++){ |
|
|
|
ships[i].print(); |
|
|
|
ships[i].placeOnBoard(board); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -87,12 +88,7 @@ public class Battleship{ |
|
|
|
for (int row = 0; row < arr.length; row++){ |
|
|
|
String s = ""; |
|
|
|
for (int col = 0; col < arr[row].length; col ++){ |
|
|
|
if (arr[row][col] == 4){ |
|
|
|
s += "+"; |
|
|
|
} |
|
|
|
else { |
|
|
|
s += " "; |
|
|
|
} |
|
|
|
s += arr[row][col]; |
|
|
|
if (col < arr[row].length - 1){ |
|
|
|
s += " "; |
|
|
|
} |
|
|
|
@ -106,4 +102,4 @@ public class Battleship{ |
|
|
|
randomizingBoard(testBoard); |
|
|
|
printBoard(testBoard); |
|
|
|
} |
|
|
|
} |
|
|
|
} |