Browse Source

Added classwide debug flag

I don't have to constantly delete and re-add stuff
master
school 7 years ago
parent
commit
bc4bf88cab
  1. 2
      Battleship.java
  2. 15
      Ship.java

2
Battleship.java

@ -36,7 +36,7 @@ public class Battleship{
int[] boundTL = {0,0};
int[] boundBR = {board[0].length-1, board.length-1};
int length;
int[] lengths = {
2,
3,

15
Ship.java

@ -2,6 +2,7 @@ import java.util.Arrays;
public class Ship{
public static final int X = 0;
public static final int Y = 1;
private static final boolean DEBUG = false;
private boolean vertical;
private int[] start;
private int[] end;
@ -175,12 +176,22 @@ public class Ship{
int c;
if (this.vertical){
for (c = this.start[Y];c <= this.end[Y];c++){
board[c][x_col] = this.length;
if (DEBUG) {
board[c][x_col] = this.length;
}
else {
board[c][x_col] = 4;
}
}
}
else {
for (c = this.start[X];c <= this.end[X];c++){
board[y_col][c] = this.length;
if (DEBUG) {
board[y_col][c] = this.length;
}
else {
board[y_col][c] = 4;
}
}
}
}

Loading…
Cancel
Save