-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCard.java
51 lines (39 loc) · 1.04 KB
/
Card.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
import java.io.Serializable;
public class Card implements Serializable {
private static final long serialVersionUID = 123L;
private CardType value;
private Suit suit;
private String name;
public Card(Suit suit, CardType value) {
this.suit = suit;
this.value = value;
setName();
}
public CardType getCardType() {
return this.value;
}
public Suit getSuit() {
return this.suit;
}
public String getName() {
return this.name;
}
private void setName() {
String aSuit = this.suit.toString();
String aValue = this.value.toString();
this.name = aValue + " of " + aSuit;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
// If the object is compared with itself then return true
if (obj == this) {
return true;
}
// Cast obj to Card so that we can compare data members
final Card toCompare = (Card) obj;
return this.name.equals(toCompare.getName());
}
}