-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
45 lines (38 loc) · 878 Bytes
/
Card.java
File metadata and controls
45 lines (38 loc) · 878 Bytes
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
public class Card {
public static final String HEARTS = "H";
public static final String SPADES = "S";
public static final String DIAMONDS = "D";
public static final String CLUBS = "C";
public static final int ACE = 1;
public static final int JACK = 11;
public static final int QUEEN = 12;
public static final int KING = 13;
private String suit;
private int number;
public Card(String suit, int number){
this.suit = suit;
this.number = number;
}
public String toText(){
return (getRealNumber() + suit);
}
public String getSuit() {
return suit;
}
public int getNumber() {
return number;
}
public String getRealNumber(){
if(number == ACE){
return "A";
}else if(number == JACK){
return "J";
}else if(number == QUEEN){
return "Q";
}else if(number == KING){
return "K";
}else{
return Integer.toString(number);
}
}
}