forked from jarolrod/java-solitaire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
94 lines (75 loc) · 2 KB
/
Card.java
File metadata and controls
94 lines (75 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package code;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
public class Card extends Rectangle {
private String suit;
private String rank;
private String color;
private Image cardImage;
private Shape cardObj;
private String id;
private String imageLocation;
private boolean draggable;
public Card(String suit, String rank) {
super(146,194);
this.suit = suit;
this.rank = rank;
draggable = false;
imageLocation = "/resources/card_images/" + rank + suit + ".gif";
super.setArcHeight(15);
super.setArcWidth(15);
super.setStyle("-fx-background-image: url(" + imageLocation +"); -fx-background-repeat: no-repeat;-fx-background-size: contain;");
Image test = new Image(imageLocation);
super.setFill(new ImagePattern(test));
super.setStroke(Color.BLACK);
super.setManaged(false);
id = rank + suit;
super.setId(id);
updateColor(suit);
}
public boolean getDraggable() {
return this.draggable;
}
public void setDraggable(boolean value) {
this.draggable = value;
}
public String getSuit() {
return this.suit;
}
public int getRank() {
if(this.rank.equals("a")) return 1;
if(this.rank.equals("j")) return 11;
if(this.rank.equals("q")) return 12;
if(this.rank.equals("k")) return 13;
int rankToInt = Integer.parseInt(this.rank);
return rankToInt;
}
public String getStringRank() {
return this.rank;
}
public String getColor() {
return this.color;
}
public Image getImage() {
return this.cardImage;
}
public Shape getCardObj() {
return this.cardObj;
}
public String getID() {
return this.id;
}
public String getImageLocation() {
return this.imageLocation;
}
public Image getCardImage() {
return this.cardImage;
}
public void updateColor(String suit) {
if ((suit.equals("d")) || (suit.equals("h"))) this.color = "red";
else if ((suit.equals("c")) || (suit.equals("s"))) this.color = "black";
}
}