Skip to content
Snippets Groups Projects
Commit f929b351 authored by Krishkumar Sandipkumar Patel's avatar Krishkumar Sandipkumar Patel
Browse files

Fixed the bug in drawHorizontal and drawVertical method. Which was to write...

Fixed the bug in drawHorizontal and drawVertical method. Which was to write code that would throw an exception when the user tries to draw a line on top of an existing line.
parent a5d178c1
No related branches found
No related tags found
No related merge requests found
......@@ -150,6 +150,9 @@ public class DotsAndBoxesGrid {
}
// FIXME: You need to throw an exception if the line was already drawn.
if (getHorizontal(x, y)) {
throw new IllegalArgumentException(String.format("line at coordinate (%d, %d) already exists. Try other coordinates", x, y));
}
this.horizontals[x][y] = true; // otherwise set the horizontal line to true
......@@ -182,6 +185,9 @@ public class DotsAndBoxesGrid {
// FIX this too, whether vertical line was already drawn or not
// You need to throw an exception if the line was already drawn.
if (getVertical(x, y)) {
throw new IllegalArgumentException(String.format("line at coordinate (%d, %d) already exists. Try other coordinates", x, y));
}
this.verticals[x][y] = true; // otherwise set the vertical line to true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment