diff --git a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java index a9e7c5b6639e8a2a8728809d9b17c8d155baf9b6..ded636deea69999972668f09d6564999c8ce879a 100644 --- a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java +++ b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java @@ -112,9 +112,14 @@ public class DotsAndBoxesGrid { // A box is complete if the north and south horizontals and the east and west verticals have all been drawn. // FIXME: You'll need to fix this code (after writing a test first). - return true; + if (getHorizontal(0, 0) && getHorizontal(0, 1) && getVertical(0, 0) && getVertical(1, 0)) { + return true; + } + else + return false; } + /** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */ private boolean claimBox(int x, int y, int p) { if (boxComplete(x, y)) { @@ -140,6 +145,7 @@ public class DotsAndBoxesGrid { } // FIXME: You need to throw an exception if the line was already drawn. + if (getHorizontal(x, y)) throw new IllegalStateException(); this.horizontals[x][y] = true;