Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TA2_SWT
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Nick-Luis Achtmann
TA2_SWT
Commits
ee702ad9
Commit
ee702ad9
authored
1 month ago
by
Nick
Browse files
Options
Downloads
Patches
Plain Diff
Restart und Draw
parent
02d25b6a
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Fehler fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Scene.fxml
+10
-10
10 additions, 10 deletions
src/Scene.fxml
src/SceneController.java
+19
-1
19 additions, 1 deletion
src/SceneController.java
with
29 additions
and
11 deletions
src/Scene.fxml
+
10
−
10
View file @
ee702ad9
...
...
@@ -27,18 +27,18 @@
<RowConstraints
minHeight=
"10.0"
prefHeight=
"30.0"
vgrow=
"SOMETIMES"
/>
</rowConstraints>
<children>
<Button
fx:id=
"button1"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"0"
GridPane.halignment=
"CENTER"
GridPane.
column
Index=
"0"
GridPane.valignment=
"CENTER"
/>
<Button
fx:id=
"button2"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
0
"
GridPane.
column
Index=
"
1
"
/>
<Button
fx:id=
"button3"
layoutX=
"115.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
0
"
GridPane.
column
Index=
"
2
"
/>
<Button
fx:id=
"button4"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
1
"
GridPane.
column
Index=
"
0
"
/>
<Button
fx:id=
"button5"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"1"
GridPane.
column
Index=
"1"
/>
<Button
fx:id=
"button6"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
1
"
GridPane.
column
Index=
"
2
"
/>
<Button
fx:id=
"button7"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
2
"
GridPane.
column
Index=
"
0
"
/>
<Button
fx:id=
"button8"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"
2
"
GridPane.
column
Index=
"
1
"
/>
<Button
fx:id=
"button9"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
row
Index=
"2"
GridPane.
column
Index=
"2"
/>
<Button
fx:id=
"button1"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"0"
GridPane.halignment=
"CENTER"
GridPane.
row
Index=
"0"
GridPane.valignment=
"CENTER"
/>
<Button
fx:id=
"button2"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
1
"
GridPane.
row
Index=
"
0
"
/>
<Button
fx:id=
"button3"
layoutX=
"115.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
2
"
GridPane.
row
Index=
"
0
"
/>
<Button
fx:id=
"button4"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
0
"
GridPane.
row
Index=
"
1
"
/>
<Button
fx:id=
"button5"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"1"
GridPane.
row
Index=
"1"
/>
<Button
fx:id=
"button6"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
2
"
GridPane.
row
Index=
"
1
"
/>
<Button
fx:id=
"button7"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
0
"
GridPane.
row
Index=
"
2
"
/>
<Button
fx:id=
"button8"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"
1
"
GridPane.
row
Index=
"
2
"
/>
<Button
fx:id=
"button9"
layoutX=
"10.0"
layoutY=
"10.0"
mnemonicParsing=
"false"
onAction=
"#handleButtonClick"
prefHeight=
"133.0"
prefWidth=
"142.0"
text=
" "
GridPane.
column
Index=
"2"
GridPane.
row
Index=
"2"
/>
</children>
</GridPane>
<Button
layoutX=
"446.0"
layoutY=
"170.0"
mnemonicParsing=
"false"
prefHeight=
"30.0"
prefWidth=
"82.0"
text=
"Restart"
/>
<Button
layoutX=
"446.0"
layoutY=
"170.0"
mnemonicParsing=
"false"
onAction=
"#restartGame"
prefHeight=
"30.0"
prefWidth=
"82.0"
text=
"Restart"
/>
<Label
fx:id=
"turnlabel"
alignment=
"CENTER"
contentDisplay=
"CENTER"
layoutX=
"409.0"
layoutY=
"263.0"
prefHeight=
"30.0"
prefWidth=
"156.0"
text=
"Your Turn"
textAlignment=
"CENTER"
>
<font>
<Font
name=
"Ink Free"
size=
"25.0"
/>
...
...
This diff is collapsed.
Click to expand it.
src/SceneController.java
+
19
−
1
View file @
ee702ad9
...
...
@@ -13,6 +13,8 @@ public class SceneController {
private
Actor
player
;
private
Actor
enemy
;
private
int
moves
=
0
;
public
int
playerTurn
=
1
;
public
void
initData
(
Board
board
,
Actor
player
,
Actor
enemy
)
{
...
...
@@ -82,6 +84,17 @@ public class SceneController {
}
}
@FXML
private
void
restartGame
(
ActionEvent
event
)
{
initData
(
new
Board
(),
this
.
player
,
this
.
enemy
);
moves
=
0
;
playerTurn
=
1
;
initialize
();
for
(
int
i
=
0
;
i
<
buttonList
.
size
();
i
++){
buttonList
.
get
(
i
).
setText
(
" "
);
}
}
// Diese Funktion wird beim Button-Click aufgerufen
@FXML
private
void
handleButtonClick
(
ActionEvent
event
)
{
...
...
@@ -98,13 +111,18 @@ public class SceneController {
if
(
buttonText
.
equals
(
" "
)
&&
playerTurn
==
1
)
{
// Setze X
pressedButton
.
setText
(
"X"
);
moves
++;
player
.
makeMove
(
board
,
col
,
row
);
playerTurn
=
0
;
over
();
if
(
moves
==
9
){
turnlabel
.
setText
(
"Draw!"
);
playerTurn
=
-
1
;
}
if
(
playerTurn
==
0
){
aiTurn
();
moves
++;
over
();
}
board
.
printBoard
();
...
...
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