-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intro_to_ComputerScience_Lab2Card.java
75 lines (51 loc) · 1.25 KB
/
Intro_to_ComputerScience_Lab2Card.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
package pokerBase;
import java.util.Comparator;
import pokerEnums.eRank;
import pokerEnums.eSuit;
public class Card implements Comparable {
private eSuit eSuit;
private eRank eRank;
private int iCardNbr;
private boolean bWild;
Card()
{
}
public Card(pokerEnums.eSuit eSuit, pokerEnums.eRank eRank, int iCardNbr) {
super();
this.eSuit = eSuit;
this.eRank = eRank;
this.iCardNbr = iCardNbr;
}
public eSuit geteSuit() {
return eSuit;
}
public eRank geteRank() {
return eRank;
}
public int getiCardNbr() {
return iCardNbr;
}
public void seteSuit(eSuit eSuit) {
this.eSuit = eSuit;
}
public void seteRank(eRank eRank) {
this.eRank = eRank;
}
public boolean isbWild() {
return bWild;
}
public void setbWild(boolean bWild) {
this.bWild = bWild;
}
public static Comparator<Card> CardRank = new Comparator<Card>() {
public int compare(Card c1, Card c2) {
int Cno1 = c1.geteRank().getiRankNbr();
int Cno2 = c2.geteRank().getiRankNbr();
/*For descending order*/
return Cno2 - Cno1;
}};
public int compareTo(Object o) {
Card c = (Card) o;
return c.geteRank().compareTo(this.geteRank());
}
}