Skip to content
Snippets Groups Projects
Commit 534b7bad authored by Simit Shrestha's avatar Simit Shrestha
Browse files

Updated code for fixing bugs

parent 00bcf105
No related tags found
No related merge requests found
......@@ -139,7 +139,10 @@ public class DotsAndBoxesGrid {
throw new IndexOutOfBoundsException(String.format("y was %d, which is out of range. Range is 0 to %d", y, height));
}
// FIXME: You need to throw an exception if the line was already drawn.
// throws an exception if the line was already drawn.
if (horizontals[x][y]) {
throw new IllegalStateException(String.format("Horizontal line at (%d, %d) already drawn", x, y));
}
this.horizontals[x][y] = true;
......@@ -170,7 +173,10 @@ public class DotsAndBoxesGrid {
throw new IndexOutOfBoundsException(String.format("y was %d, which is out of range. Range is 0 to %d", y, height - 1));
}
// You need to throw an exception if the line was already drawn.
// throws an exception if the line was already drawn.
if (verticals[x][y]) {
throw new IllegalStateException(String.format("Vertical line at (%d, %d) already drawn", x, y));
}
this.verticals[x][y] = true;
// Try to claim the north or south boxes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment