Skip to content
Snippets Groups Projects
Commit a1996e40 authored by Saurav Saurav's avatar Saurav Saurav
Browse files

bug fixes

parent c03fdfc1
No related branches found
No related tags found
No related merge requests found
Pipeline #1518 failed
package dotsandboxes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Observer;
......@@ -113,8 +112,11 @@ 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).
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. */
private boolean claimBox(int x, int y, int p) {
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment