-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriple.java
35 lines (32 loc) · 1.07 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
/**
* this is a subclass extends Hand class to model a hand of Triple
* @author Fan Zheyu
*
*/
public class Triple extends Hand{
/**
* a constructor for building a Triple with the specified player as well as a list of cards
* @param player the player (object) that holds this hand
* @param cards a CardList suggesting the content of this hand of cards
*/
public Triple(CardGamePlayer player, CardList cards) {
super(player, cards);
}
/**
* Check if the hand is a valid Triple
* @return if it is valid.
*/
public boolean isValid() {
// size is 3 and all cards are equal.
return this.size() == 3 &&
(this.getCard(0).getRank() == this.getCard(1).getRank()
&& this.getCard(1).getRank() == this.getCard(2).getRank());
}
/**
* get the string specifying the type of this hand, which is Triple.
* @return the string specifying the type of this hand.
*/
public String getType() {
return "Triple";
}
}