-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
86 lines (66 loc) · 2.35 KB
/
Card.java
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
public class Card {
//suit value of H,C,S,D for heart, club, spade, diamond respectively
private String suit;
//value for display and scoring purposes
private int value;
//array that contains the row then column of the card on the game board
private int[] location;
/*two letter string for display purposes on the board.
* for cards 2-10, will contain first letter of suit and value.
* for face cards, will contain first letter of suit and first letter of the face card's name.
* for ace will contain first letter of suit and 'A.'
*/
private String cardIcon;
/*constructor will create different types of cards as needed. The highCard parameter is used to create the cardIcon for cards the face cards
* and ace because their display on the board will not use their value as per instructions.
* There will be 4 types of cards needed:
* (1) Display cards for initial empty position display. Will have null suit, value will be the position i'th postion in
* the board that the user chooses to make a move
* (2) Cards 2-10, whose value is part of their display.
* (3) Face cards, who have a value of 10 and display the first char of suit and name.
* (4) The ace, which will have default value of 1 and display the first char of suit and name.
*/
public Card(String s, int v, String highCard) {
this.suit = s;
this.value = v;
//check if display card.
if((highCard == null) && s == null) {
//set the display variable for display cards
this.cardIcon = Integer.toString(v);
//check if 2-10 card
}else if((highCard == null) && (s != null)) {
//set display variable to value and first letter of suit
this.cardIcon = Integer.toString(v)+ s;
}
// otherwise, must be a face card or ace.
else {
//set display variable to the highcard parameter that will be initialized during card construction.
this.cardIcon = highCard;
}
}
//getters and setters
public String getCardIcon() {
return cardIcon;
}
public void setCardIcon(String cardIcon) {
this.cardIcon = cardIcon;
}
public int[] getLocation() {
return location;
}
public void setLocation(int[] location) {
this.location = location;
}
public String getSuit() {
return suit;
}
public void setSuit(String suit) {
this.suit = suit;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}