- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCard.java
More file actions
Latest commit
35 lines (23 loc) · 742 Bytes
/
Copy pathCard.java
File metadata and controls
35 lines (23 loc) · 742 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
//Defining the Card Class
publicclassCardimplementsComparable<Card> {
// This attribute is for the rank of the card.
// (i.e 2,3,4,ace... etc.)
Stringrank;
// This attribute is for the suite of the card.
// (i.e heart, diamond, spade, or club)
Stringsuit;
publicStringgetRank() {
returnrank;
}
//Constructor for the Card Class giving it a rank and a suit.
Card(Stringrank, Stringsuit) {
this.rank = rank;
this.suit = suit;
}
@Override
publicintcompareTo(Cardc) {
intcomCard = Integer.parseInt(c.getRank());
intintRank = Integer.parseInt(this.rank);
returnintRank-comCard;
}
}