-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRound.java
More file actions
49 lines (40 loc) · 1.08 KB
/
Round.java
File metadata and controls
49 lines (40 loc) · 1.08 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
import java.util.HashMap;
/**
* Write a description of class Round here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Round
{
private final HashMap<Player,Boolean> decisions = new HashMap<Player,Boolean>();
private final int c;
private final int numEnterers;
public Round(Player[] players, int c) {
this.c = c;
int enterers = 0;
for(Player p : players) {
if(p.getLastDecision()) enterers++;
decisions.put(p,p.getLastDecision());
}
numEnterers = enterers;
}
public boolean didPlayerWin(Player p) {
return decisions.get(p) == didEnterersWin();
}
public int getC() {
return c;
}
public boolean getPlayerDecision(Player p) {
return decisions.get(p);
}
public boolean didEnterersWin() {
return numEnterers <= c;
}
public boolean areEnterersMostCommon() {
return numEnterers > decisions.size()/2;
}
public int getNumEnterers() {
return numEnterers;
}
}