-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
36 lines (32 loc) · 791 Bytes
/
Copy pathPair.java
File metadata and controls
36 lines (32 loc) · 791 Bytes
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
/**
* Pair class is a subclass of Hand which model a pair hand
* and implement the method in Hand
*
* @author Chan Yuk Yin (UID: 3035786574)
*/
public class Pair extends Hand{
public Pair(CardGamePlayer player, CardList cards){
super(player, cards);
}
/**
* Check whether the hand is a valid pair or not
* @return boolean
*/
public boolean isValid(){
if (!this.isEmpty()){
if (this.size() == 2){
if (this.getCard(0).getRank() == this.getCard(1).getRank()){
return true;
}
}
}
return false;
}
/**
* Return the type of hand
* @return String
*/
public String getType(){
return "Pair";
}
}