-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCard.java
More file actions
35 lines (23 loc) · 742 Bytes
/
Card.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
public class Card implements Comparable<Card> {
// This attribute is for the rank of the card.
// (i.e 2,3,4,ace... etc.)
String rank;
// This attribute is for the suite of the card.
// (i.e heart, diamond, spade, or club)
String suit;
public String getRank() {
return rank;
}
//Constructor for the Card Class giving it a rank and a suit.
Card(String rank, String suit) {
this.rank = rank;
this.suit = suit;
}
@Override
public int compareTo(Card c) {
int comCard = Integer.parseInt(c.getRank());
int intRank = Integer.parseInt(this.rank);
return intRank-comCard;
}
}