-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriple.java
46 lines (43 loc) · 1.04 KB
/
Triple.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
/**
* This class is used to model a hand of Triple
*
* @author Chan Sze Wing
*
*/
public class Triple extends Hand {
/**
* Building a hand of Triple with a player and their chosen list of cards
*
* @param player the index of player
* @param cards the list of selected cards
*/
public Triple(CardGamePlayer player, CardList cards) {
super(player, cards);
}
/**
* Check if the hand is a valid Triple hand
*
* @return true if the hand is Triple, otherwise false
*/
public boolean isValid() {
if (this.size() == 3) {
int temp = this.getCard(0).getRank();
for (int i = 1; i < this.size(); i++) {
if (this.getCard(i).getRank() != temp) {
return false;
}
}
return true;
} else {
return false;
}
}
/**
* Return the hand's type
*
* @return the string "Triple"
*/
public String getType() {
return "Triple";
}
}