Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Card game
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Emil Ruud
Card game
Commits
fac5488b
Commit
fac5488b
authored
10 months ago
by
emilruud
Browse files
Options
Downloads
Patches
Plain Diff
Removed borders, and made it so that card analyticts resets when dealing a new hand.
parent
1b1ec4aa
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
src/main/java/no/ntnu/idatx2003/oblig3/cardgame/view/CardGameGUI.java
+17
-14
17 additions, 14 deletions
...a/no/ntnu/idatx2003/oblig3/cardgame/view/CardGameGUI.java
with
17 additions
and
14 deletions
src/main/java/no/ntnu/idatx2003/oblig3/cardgame/view/CardGameGUI.java
+
17
−
14
View file @
fac5488b
...
...
@@ -21,11 +21,10 @@ import no.ntnu.idatx2003.oblig3.cardgame.model.PlayingCard;
public
class
CardGameGUI
extends
Application
{
private
HBox
cardsBox
;
private
BorderPane
root
;
private
HandofCards
currentHand
;
// Make currentHand a class member variable
private
Text
sumTextLabel
;
private
Label
sumNumberLabel
;
private
Label
sumNumberLabel
;
private
Label
flushLabel
;
...
...
@@ -35,11 +34,11 @@ public class CardGameGUI extends Application {
@Override
public
void
start
(
Stage
primaryStage
)
{
root
=
new
BorderPane
();
// Initialize root as a BorderPane
cardsBox
=
new
HBox
(
20
);
// Initialize cardsBox as an HBox with spacing of 20
cardsBox
.
setStyle
(
"-fx-border-color: red; -fx-border-width: 2;"
);
// Set border for cardsBox
BorderPane
root
=
new
BorderPane
();
// Initialize root as a BorderPane
cardsBox
=
new
HBox
(
20
);
// Initialize cardsBox as an HBox with spacing of 20
cardsBox
.
setAlignment
(
Pos
.
CENTER
);
// Set the alignment of the HBox to CENTER
cardsBox
.
setPadding
(
new
Insets
(
10
,
10
,
20
,
10
));
//
cardsBox.setStyle("-fx-border-color: red; -fx-border-width: 2;"); // Set border for cardsBox
root
.
setTop
(
cardsBox
);
// Add cardsBox to the left region of the BorderPane
...
...
@@ -49,7 +48,7 @@ public class CardGameGUI extends Application {
Scene
scene
=
new
Scene
(
root
,
800
,
500
);
primaryStage
.
setTitle
(
"Card Game"
);
sumTextLabel
=
new
Text
(
"Sum of the faces: "
);
Text
sumTextLabel
=
new
Text
(
"Sum of the faces: "
);
sumNumberLabel
=
new
Label
(
"0 "
);
HBox
sumBox
=
new
HBox
(
sumTextLabel
,
sumNumberLabel
);
// Create a HBox
VBox
leftBox
=
new
VBox
(
sumBox
);
...
...
@@ -62,21 +61,21 @@ public class CardGameGUI extends Application {
leftBox
.
setAlignment
(
Pos
.
TOP_LEFT
);
// Set the alignment of the VBox to CENTER
leftBox
.
setPadding
(
new
Insets
(
10
,
10
,
10
,
10
));
leftBox
.
setStyle
(
"-fx-border-color: blue; -fx-border-width: 2;"
);
// Set border for leftBox
//
leftBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for leftBox
leftBox
.
setSpacing
(
20
);
Text
flushText
=
new
Text
(
"Flush: "
);
flushLabel
=
new
Label
(
" "
);
HBox
flushBox
=
new
HBox
(
flushText
,
flushLabel
);
// Create a HBox
flushBox
.
setPadding
(
new
Insets
(
10
,
10
,
10
,
10
));
flushBox
.
setStyle
(
"-fx-border-color: green; -fx-border-width: 2;"
);
//
flushBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
VBox
rightBox
=
new
VBox
(
flushBox
);
Text
heartsText
=
new
Text
(
"Cards of Hearts: "
);
heartsLabel
=
new
Label
(
" "
);
HBox
heartsBox
=
new
HBox
(
heartsText
,
heartsLabel
);
// Create a HBox
heartsBox
.
setPadding
(
new
Insets
(
10
,
10
,
10
,
10
));
heartsBox
.
setStyle
(
"-fx-border-color: green; -fx-border-width: 2;"
);
//
heartsBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
rightBox
.
getChildren
().
add
(
heartsBox
);
...
...
@@ -85,13 +84,17 @@ public class CardGameGUI extends Application {
analytics
.
setSpacing
(
20
);
analytics
.
setPadding
(
new
Insets
(
50
,
10
,
100
,
10
));
analytics
.
setAlignment
(
Pos
.
BOTTOM_LEFT
);
analytics
.
setStyle
(
"-fx-border-color: red; -fx-border-width: 2;"
);
//
analytics.setStyle("-fx-border-color: red; -fx-border-width: 2;");
root
.
setBottom
(
analytics
);
Button
dealButton
=
new
Button
(
"Deal a new hand"
);
dealButton
.
setOnAction
(
event
->
{
sumNumberLabel
.
setText
(
"0"
);
flushLabel
.
setText
(
" "
);
queenOfSpadesLabel
.
setText
(
" "
);
heartsLabel
.
setText
(
" "
);
DeckOfCards
deck
=
new
DeckOfCards
();
currentHand
=
deck
.
dealHand
(
5
);
displayHand
(
currentHand
);
...
...
@@ -110,7 +113,7 @@ public class CardGameGUI extends Application {
buttonBox
.
setAlignment
(
Pos
.
TOP_RIGHT
);
// Set the alignment of the VBox to CENTER
buttonBox
.
getChildren
().
add
(
dealButton
);
// Add the button to the VBox
buttonBox
.
getChildren
().
add
(
CheckButton
);
// Add the button to the VBox
buttonBox
.
setStyle
(
"-fx-border-color: blue; -fx-border-width: 2;"
);
// Set border for rightBox
//
buttonBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for rightBox
root
.
setRight
(
buttonBox
);
// Add the VBox to the right region of the BorderPane
...
...
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