Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DotsAndBoxs
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jnepali
DotsAndBoxs
Commits
53af0e51
Commit
53af0e51
authored
Jul 31, 2024
by
jnepali
Browse files
Options
Downloads
Plain Diff
Merge branch 'bugfix/1-fix-assignment-errors' into 'main'
fixed the test cases and main code See merge request
!1
parents
dd640054
a81670d4
Branches
main
No related tags found
1 merge request
!1
fixed the test cases and main code
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/dotsandboxes/Main.java
+5
-5
5 additions, 5 deletions
src/main/java/dotsandboxes/Main.java
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+33
-1
33 additions, 1 deletion
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
with
38 additions
and
6 deletions
src/main/java/dotsandboxes/Main.java
+
5
−
5
View file @
53af0e51
...
...
@@ -8,11 +8,11 @@ public class Main {
public
static
void
main
(
String
...
args
)
throws
Exception
{
JFrame
mainWindow
=
new
JFrame
(
"Dots and Boxes"
);
JFrame
mainWindow
=
new
JFrame
(
"
Welcome to
Dots and Boxes
Games
"
);
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
15
,
8
,
2
);
// FIXME: Update this label to show your name and student number
JLabel
label
=
new
JLabel
(
"Name:
(Your name and student number goes here)
"
);
JLabel
label
=
new
JLabel
(
"Name:
Jaya Nepali
"
);
JPanel
borderPane
=
new
JPanel
(
new
BorderLayout
());
borderPane
.
add
(
label
,
BorderLayout
.
SOUTH
);
...
...
This diff is collapsed.
Click to expand it.
src/test/java/dotsandboxes/DotsAndBoxesGridTest.java
+
33
−
1
View file @
53af0e51
...
...
@@ -28,4 +28,36 @@ public class DotsAndBoxesGridTest {
}
// FIXME: You need to write tests for the two known bugs in the code.
@Test
public
void
testBoxCompletionDetection
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
4
,
3
,
2
);
// Draw four sides of a box (not completing it)
grid
.
drawHorizontal
(
0
,
0
,
1
);
// Top
grid
.
drawVertical
(
0
,
0
,
1
);
// Left
grid
.
drawHorizontal
(
0
,
1
,
1
);
// Bottom
grid
.
drawVertical
(
1
,
0
,
1
);
//Right
assertTrue
(
grid
.
boxComplete
(
0
,
0
),
"The box should be completed."
);
}
@Test
public
void
testDrawHorizontalLineAlreadyDrawn
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
4
,
4
,
2
);
grid
.
drawHorizontal
(
0
,
0
,
1
);
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawHorizontal
(
0
,
0
,
1
);
// Drawing the same line should throw an exception
});
}
@Test
public
void
testDrawVerticalLineAlreadyDrawn
()
{
DotsAndBoxesGrid
grid
=
new
DotsAndBoxesGrid
(
4
,
4
,
2
);
grid
.
drawVertical
(
0
,
0
,
1
);
assertThrows
(
IllegalStateException
.
class
,
()
->
{
grid
.
drawVertical
(
0
,
0
,
1
);
// Drawing the same line should throw an exception
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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