-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCard.java
More file actions
49 lines (42 loc) · 1023 Bytes
/
Card.java
File metadata and controls
49 lines (42 loc) · 1023 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
46
47
48
49
public class Card {
boolean faceCard = false;
int number;
String suit;
String royal;
String[] royalFaces = new String[]{"Jack", "Queen", "King"};
public Card(int number, String suit){
this.number = number;
this.suit = suit;
this.royal = "";
if (number > 10){
this.number = 10;
faceCard = true;
this.royal = royalFaces[number - 11];
}
if (number == 1){
this.number = 11;
}
}
public int getNum(){
return this.number;
}
public void setNum(int num){
this.number = num;
}
public String getSuit(){
return this.suit;
}
public String getFace(){
return this.royal;
}
public boolean isFace(){
return this.faceCard;
}
@Override
public String toString() {
if (faceCard == true){
return this.royal + " of " + this.suit;
}
return this.number + " of " + this.suit;
}
}