-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
46 lines (39 loc) · 1000 Bytes
/
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
class Card {
// Fields //
private String rank; // card's rank //
private String suit; // card's suit //
private int pointValue; // card's point value //
// Constructor //
public Card(String rank, String suit, int pointValue) {
this.rank = rank;
this.suit = suit;
this.pointValue = pointValue;
}
// Accessor Methods //
public String getRank() {
return rank;
}
public String getSuit() {
return suit;
}
public int getValue() {
return pointValue;
}
// Instance Methods //
// equalCards - comparing whether two instance cards are equal. If not, then determining which card is greater and returning a string message //
public boolean equalCards(Card a, Card b) {
if(a.getValue() > b.getValue()) {
return false;
}
else if(a.getValue() < b.getValue()) {
return false;
}
else {
return true;
}
}
@Override
public String toString() {
return rank + " of " + suit + " (" + pointValue + ")";
}
}