Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arbeidskrav_4
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
Isak Kallestad Mandal
Arbeidskrav_4
Commits
c63d2a21
Commit
c63d2a21
authored
2 years ago
by
Isak Kallestad Mandal
Browse files
Options
Downloads
Patches
Plain Diff
Added functionality to the checkHand button
parent
94cdb39b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/ntnu/idatt2001/oblig4/cardgame/View/ApplicationFront.java
+29
-22
29 additions, 22 deletions
...ntnu/idatt2001/oblig4/cardgame/View/ApplicationFront.java
with
29 additions
and
22 deletions
src/main/java/no/ntnu/idatt2001/oblig4/cardgame/View/ApplicationFront.java
+
29
−
22
View file @
c63d2a21
package
no.ntnu.idatt2001.oblig4.cardgame.View
;
import
javafx.scene.control.TextField
;
import
javafx.scene.effect.ImageInput
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.layout.HBox
;
import
javafx.scene.shape.Rectangle
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.HandOfCards
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.PlayingCard
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.DeckOfCards
;
import
javafx.application.Application
;
import
javafx.scene.Group
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.TextField
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.layout.HBox
;
import
javafx.scene.paint.Color
;
import
javafx.scene.text.Font
;
import
javafx.scene.text.FontWeight
;
import
javafx.scene.text.Text
;
import
javafx.stage.Stage
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.DeckOfCards
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.HandOfCards
;
import
no.ntnu.idatt2001.oblig4.cardgame.Model.PlayingCard
;
public
class
ApplicationFront
extends
Application
{
...
...
@@ -80,11 +76,22 @@ public class ApplicationFront extends Application {
deckField
.
setLayoutX
(
365
);
deckField
.
setLayoutY
(
90
);
TextField
hearts
=
newTextField
(
""
,
180
,
400
,
"black"
,
"white"
,
200
,
50
,
20
);
TextField
flush
=
newTextField
(
""
,
425
,
400
,
"black"
,
"white"
,
200
,
50
,
20
);
TextField
queen
=
newTextField
(
""
,
180
,
500
,
"black"
,
"white"
,
250
,
50
,
20
);
TextField
sum
=
newTextField
(
""
,
475
,
500
,
"black"
,
"white"
,
150
,
50
,
20
);
hearts
.
setEditable
(
false
);
flush
.
setEditable
(
false
);
queen
.
setEditable
(
false
);
sum
.
setEditable
(
false
);
dealHand
.
setOnAction
(
e
->
{
hand
.
setHand
(
deck
.
dealHand
(
NUM_CARDS
));
handField
.
getChildren
().
clear
();
for
(
PlayingCard
card
:
hand
.
getHand
())
{
Image
image
=
new
Image
(
"file:src/main/resources/"
+
card
.
getSuit
()
+
card
.
getFace
()
+
".png"
);
Image
image
=
new
Image
(
"file:src/main/resources/"
+
card
.
getSuit
()
+
card
.
getFace
()
+
".png"
);
ImageView
cardFront
=
new
ImageView
(
image
);
cardFront
.
setFitWidth
(
75
);
cardFront
.
setFitHeight
(
90
);
...
...
@@ -92,20 +99,19 @@ public class ApplicationFront extends Application {
}
});
checkHand
.
setOnAction
(
e
->
{
hearts
.
setText
(
hand
.
hasHearts
());
flush
.
setText
(
hand
.
isFlush
());
queen
.
setText
(
hand
.
hasQueenOfSpades
());
sum
.
setText
(
String
.
valueOf
(
hand
.
calculateSumOfHand
()));
});
Group
root
=
new
Group
(
dealHand
,
checkHand
,
handField
,
deckField
);
Group
root
=
new
Group
(
dealHand
,
checkHand
,
handField
,
deckField
,
hearts
,
flush
,
queen
,
sum
);
Scene
scene
=
new
Scene
(
root
,
800
,
600
,
Color
.
DARKSEAGREEN
);
stage
.
setScene
(
scene
);
return
scene
;
}
// Image cardBack = newImage("file:src/main/resources/back1.png", 100, 100, 100, 100);
// Rectangle cardBackRect = new Rectangle(100, 100, 100 , 100);
// ImageInput imageInput = new ImageInput(cardBack, 100, 100);
// cardBackRect.setEffect(imageInput);
public
Image
newImage
(
String
path
,
int
x
,
int
y
,
int
width
,
int
height
)
{
Image
image
=
new
Image
(
path
);
...
...
@@ -117,6 +123,7 @@ public class ApplicationFront extends Application {
imageView
.
setPreserveRatio
(
true
);
return
image
;
}
public
Button
newGameButton
(
String
text
,
int
x
,
int
y
,
String
borderColor
,
String
backgroundColor
,
int
width
,
int
height
,
int
fontSize
)
{
Button
button
=
new
Button
(
text
);
...
...
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