-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandType.java
More file actions
63 lines (49 loc) · 1.23 KB
/
Copy pathHandType.java
File metadata and controls
63 lines (49 loc) · 1.23 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
/**
* COSC 310-001 Card Games
* HandType.java
*
* A class to setup a way to rank the hand a player has for 3 card
* poker.
*
* @author Colin Diorio
*/
package main;
public class HandType {
private HandRank rank;
private int[] values;
// Constructor
public HandType(HandRank rank, int[] values) {
// Gives the first value more power based off the hand rank.
values[0] = ( int ) ( values[0] *
Math.pow( 10, rank.ordinal() ) );
this.rank = rank;
this.values = values;
}
/**
* A way to return the hand type in the way someone would say it.
*/
public String toString() {
HandRank rank = this.rank;
String name = this.rank.toString();
// Pair and High have to include the value of the card.
if (rank == HandRank.PAIR)
name += " OF " + Worth.values()[(values[0] / 10) - 2] +
"S";
if (rank == HandRank.HIGH)
name = Worth.values()[values[0] - 2] + " " + name;
return name;
}
// Getters and Setters
public HandRank getRank() {
return rank;
}
public void setRank(HandRank rank) {
this.rank = rank;
}
public int[] getValues() {
return values;
}
public void setValues(int[] values) {
this.values = values;
}
}