Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Mathdoku
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
tmp1u19
Mathdoku
Commits
b05dda14
Commit
b05dda14
authored
5 years ago
by
tmp1u19
Browse files
Options
Downloads
Patches
Plain Diff
Add the hint functionality and the solver of the board
parent
be4cb1b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Handler.java
+25
-4
25 additions, 4 deletions
Handler.java
with
25 additions
and
4 deletions
Handler.java
+
25
−
4
View file @
b05dda14
import
javafx.animation.*
;
import
javafx.event.ActionEvent
;
import
javafx.event.EventHandler
;
import
javafx.geometry.Insets
;
import
javafx.scene.Node
;
import
javafx.scene.control.Button
;
...
...
@@ -717,10 +719,29 @@ public class Handler {
return
true
;
}
public
void
solveBoard
(
Button
solve
,
GridPane
grid
,
int
n
)
{
solve
.
setOnAction
(
actionEvent
->
{
Solver
solver
=
new
Solver
(
n
,
grid
);
solver
.
backtracking
(
1
,
1
);
public
void
solveBoard
(
GridPane
grid
)
{
Solver
solver
=
new
Solver
(
n
,
grid
);
solver
.
backtracking
(
1
,
1
);
clear
(
grid
);
}
public
void
hint
(
Button
hint
,
GridPane
grid
)
{
hint
.
setOnAction
(
actionEvent
->
{
boolean
found
=
false
;
for
(
int
i
=
0
;
i
<
n
&&
!
found
;
i
++)
{
for
(
int
j
=
0
;
j
<
n
;
j
++)
{
if
(
cellValues
[
i
][
j
]
!=
Solver
.
solved
[
i
][
j
])
{
getCell
(
grid
,
i
,
j
).
setValue
(
Solver
.
solved
[
i
][
j
]);
cellValues
[
i
][
j
]
=
Solver
.
solved
[
i
][
j
];
found
=
true
;
break
;
}
}
}
});
}
}
...
...
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