diff --git a/Battleship.java b/Battleship.java index 89862f2..b0dc2ea 100644 --- a/Battleship.java +++ b/Battleship.java @@ -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); } -} \ No newline at end of file +} diff --git a/Ship.java b/Ship.java index fbda688..f507cfb 100644 --- a/Ship.java +++ b/Ship.java @@ -166,7 +166,7 @@ public class Ship{ // overlaps cond1 = t_s2 == o_s2; - // intersectss + // intersects cond2 = o_e1 >= t_s1; cond3 = t_e1 >= o_s1; @@ -191,13 +191,13 @@ public class Ship{ public void placeOnBoard(int[][] board){ if (this.vertical){ - for (int c = this.start[Y];c <= this.end[Y];c++){ - board[this.start[X]][c] = 4; + for (int c = this.start[X];c <= this.end[X];c++){ + board[this.start[Y]][c] = 4; } } else { - for (int c = this.start[X];c <= this.end[X];c++){ - board[c][this.start[Y]] = 4; + for (int c = this.start[Y];c <= this.end[Y];c++){ + board[c][this.start[X]] = 4; } } }