Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cosc220-a2-220188955
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nreeves5
cosc220-a2-220188955
Commits
993ab9e1
Commit
993ab9e1
authored
3 years ago
by
nreeves5
Browse files
Options
Downloads
Patches
Plain Diff
Committing bug fixed code to main branch
parent
3068f5da
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/dotsandboxes/DotsAndBoxesGrid.java
+12
-2
12 additions, 2 deletions
src/main/java/dotsandboxes/DotsAndBoxesGrid.java
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+2
-2
2 additions, 2 deletions
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
14 additions
and
4 deletions
src/main/java/dotsandboxes/DotsAndBoxesGrid.java
+
12
−
2
View file @
993ab9e1
...
...
@@ -112,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).
return
true
;
if
(
this
.
horizontals
[
x
][
y
]
==
true
&&
this
.
horizontals
[
x
][
y
+
1
]
==
true
&&
this
.
verticals
[
x
][
y
]
==
true
&&
this
.
verticals
[
x
+
1
][
y
]
==
true
)
{
return
true
;
}
return
false
;
}
/** Tries to claim a box for a player. If the box is complete, sets the ownership and returns true. */
...
...
@@ -141,6 +144,10 @@ public class DotsAndBoxesGrid {
}
// FIXME: You need to throw an exception if the line was already drawn.
if
(
this
.
horizontals
[
x
][
y
]
==
true
)
{
throw
new
IllegalStateException
(
String
.
format
(
"IllegalStateException - This line has already been drawn"
));
}
this
.
horizontals
[
x
][
y
]
=
true
;
...
...
@@ -172,6 +179,9 @@ public class DotsAndBoxesGrid {
}
// You need to throw an exception if the line was already drawn.
if
(
this
.
verticals
[
x
][
y
])
{
throw
new
IllegalStateException
(
String
.
format
(
"This line has already been drawn"
));
}
this
.
verticals
[
x
][
y
]
=
true
;
// Try to claim the north or south boxes
...
...
This diff is collapsed.
Click to expand it.
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
2
−
2
View file @
993ab9e1
...
...
@@ -32,13 +32,13 @@ public class DotsAndBoxesGridTest {
@Test
public
void
testTestingBoxComplete
()
{
logger
.
info
(
"Test of box completion test"
);
logger
.
info
(
"Drawing complete box, then asserting
in
complete state"
);
logger
.
info
(
"Drawing complete box, then asserting complete state"
);
DotsAndBoxesGrid
g
=
new
DotsAndBoxesGrid
(
4
,
4
,
1
);
g
.
drawHorizontal
(
1
,
1
,
1
);
g
.
drawHorizontal
(
1
,
2
,
1
);
g
.
drawVertical
(
1
,
1
,
1
);
g
.
drawVertical
(
2
,
1
,
1
);
assertEquals
(
fals
e
,
g
.
boxComplete
(
1
,
1
));
assertEquals
(
tru
e
,
g
.
boxComplete
(
1
,
1
));
}
@Test
...
...
This diff is collapsed.
Click to expand it.
nreeves5
@nreeves5
mentioned in issue
#1 (closed)
·
3 years ago
mentioned in issue
#1 (closed)
mentioned in issue #1
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment