Skip to content
Snippets Groups Projects
Commit a9b1040e authored by Ugochukwu Joseph Ekeh's avatar Ugochukwu Joseph Ekeh
Browse files

tried fixing bug

parent 5e784972
No related branches found
No related tags found
No related merge requests found
......@@ -106,13 +106,13 @@ public class DotsAndBoxesGrid {
* @return true if all four sides have been drawn.
*/
public boolean boxComplete(int x, int y) {
if (x >= width - 1 || x < 0 || y >= height - 1 || y < 0) {
return false;
}
if (x >= width + 1 || x < 0 || y >= height + 1 || y < 0) {
return true;
} else {
// 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;
return false;
}
/** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */
......@@ -132,10 +132,10 @@ public class DotsAndBoxesGrid {
* @return true if it completes a box
*/
public boolean drawHorizontal(int x, int y, int player) {
if (x >= width - 1 || x < 0) {
if (x >= width + 1 || x > 0) {
throw new IndexOutOfBoundsException(String.format("x was %d, which is out of range. Range is 0 to %d", x, width - 1));
}
if (y >= height || y < 0) {
if (y >= height || y > 0) {
throw new IndexOutOfBoundsException(String.format("y was %d, which is out of range. Range is 0 to %d", y, height));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment