Skip to content
Snippets Groups Projects

Issue has been fixed through commit 378c7bf3

Merged Juan Ludevid requested to merge 1-fixing-errors into main
2 files
+ 41
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -112,7 +112,8 @@ public class DotsAndBoxesGrid {
@@ -112,7 +112,8 @@ public class DotsAndBoxesGrid {
// A box is complete if the north and south horizontals and the east and west verticals have all been drawn.
// 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).
// FIXME: You'll need to fix this code (after writing a test first).
return true;
return (this.horizontals[x][y] && this.horizontals[x][y+1] && this.verticals[x][y] && this.verticals[x+1][y]);
 
}
}
/** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */
/** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */
@@ -140,7 +141,9 @@ public class DotsAndBoxesGrid {
@@ -140,7 +141,9 @@ public class DotsAndBoxesGrid {
}
}
// FIXME: You need to throw an exception if the line was already drawn.
// FIXME: You need to throw an exception if the line was already drawn.
if (this.horizontals[x][y]) {
 
throw new IllegalStateException(String.format("horizontal line at [%d][%d] has been drawn already", x, y));
 
}
this.horizontals[x][y] = true;
this.horizontals[x][y] = true;
// Try to claim the north or south boxes
// Try to claim the north or south boxes
@@ -171,7 +174,9 @@ public class DotsAndBoxesGrid {
@@ -171,7 +174,9 @@ public class DotsAndBoxesGrid {
}
}
// You need to throw an exception if the line was already drawn.
// You need to throw an exception if the line was already drawn.
if (this.verticals[x][y]) {
 
throw new IllegalStateException(String.format("Vertical line at [%d][%d] has been drawn already", x, y));
 
}
this.verticals[x][y] = true;
this.verticals[x][y] = true;
// Try to claim the north or south boxes
// Try to claim the north or south boxes
boolean claimE = claimBox(x, y, player);
boolean claimE = claimBox(x, y, player);
Loading