diff --git a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java index 32667af6c63a0287bd4f91c37682acb30c08e9a4..cbcc9f21cd461640fc1ec3255df0d319fc07a0d2 100644 --- a/src/main/java/dotsandboxes/DotsAndBoxesGrid.java +++ b/src/main/java/dotsandboxes/DotsAndBoxesGrid.java @@ -1,6 +1,5 @@ package dotsandboxes; - import java.util.ArrayList; import java.util.Arrays; import java.util.Observer; @@ -113,7 +112,10 @@ 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(x,y) && getVertical(x,y)) { + return true; + } + return false; } /** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */ @@ -141,6 +143,9 @@ public class DotsAndBoxesGrid { } // FIXME: You need to throw an exception if the line was already drawn. + if (getHorizontal(x,y)) { + throw new IllegalStateException(String.format("line x=%d,y=%d was already drawn",x,y)); + } this.horizontals[x][y] = true;