diff --git a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java index feaac4bc9a1490dfcebf3dcecb23d32242986f71..55de35e920e6c4cce970905b9603c73d8bb03acc 100644 --- a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java +++ b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java @@ -150,6 +150,9 @@ public class DotsAndBoxesGrid { } // FIXME: You need to throw an exception if the line was already drawn. + if (getHorizontal(x, y)) { + throw new IllegalArgumentException(String.format("line at coordinate (%d, %d) already exists. Try other coordinates", x, y)); + } this.horizontals[x][y] = true; // otherwise set the horizontal line to true @@ -182,6 +185,9 @@ public class DotsAndBoxesGrid { // FIX this too, whether vertical line was already drawn or not // You need to throw an exception if the line was already drawn. + if (getVertical(x, y)) { + throw new IllegalArgumentException(String.format("line at coordinate (%d, %d) already exists. Try other coordinates", x, y)); + } this.verticals[x][y] = true; // otherwise set the vertical line to true