-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
72 lines (59 loc) · 1.74 KB
/
Card.java
File metadata and controls
72 lines (59 loc) · 1.74 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
import java.awt.image.BufferedImage;
import java.util.List;
public class Card {
private final int cardClass;
private final Color cardColor;
private BufferedImage image;
public Card(int cardClass, Color color, BufferedImage image) {
this.cardClass = cardClass;
this.cardColor = color;
this.image = image;
}
public BufferedImage getImage() {
return image;
}
public int getValue() {
return cardClass;
}
public Color getColor() {
return cardColor;
}
public enum Color {
DIAMOND, HEART, SPADE, CLUB
//KARO , Herz , PIK , KREUZ
}
public boolean placeable() {
return this.getValue() == CardField.getCard().getValue() || this.getColor() == CardField.getCard().getColor();
}
public String getCardClass() {
switch(cardClass) {
case 0:
return "7";
case 1:
return "8";
case 2:
return "9";
case 3:
return "10";
case 4:
return "Jack";
case 5:
return "Queen";
case 6:
return "King";
case 7:
return "Ace";
default:
return "null";
}
}
public static void showCards(List<Card> cards) {
for (int i = 0; i < cards.size(); i++) {
System.out.print(" ");
showCard(cards.get(i));
}
}
public static void showCard(Card card) {
System.out.println(card.getCardClass() + " | " + card.getColor());
}
}