From bc4bf88cab5301c137872e92c150a4670d275fae Mon Sep 17 00:00:00 2001 From: school Date: Fri, 5 Oct 2018 12:54:55 -0500 Subject: [PATCH] Added classwide debug flag I don't have to constantly delete and re-add stuff --- Battleship.java | 2 +- Ship.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Battleship.java b/Battleship.java index 32c893b..82b686f 100644 --- a/Battleship.java +++ b/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, diff --git a/Ship.java b/Ship.java index 7291063..c993749 100644 --- a/Ship.java +++ b/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; + } } } }