forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlayer.java
More file actions
33 lines (33 loc) · 848 Bytes
/
Copy pathPlayer.java
File metadata and controls
33 lines (33 loc) · 848 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
public class Player {
private String name;
private Strategy strategy;
private int winCount;
private int loseCount;
private int gameCount;
public Player(String name, Strategy strategy) {
this.name = name;
this.strategy = strategy;
}
public Hand nextHand() {
return this.strategy.next();
}
public void win() {
this.strategy.study(true);
this.winCount++;
this.gameCount++;
}
public void lose() {
this.strategy.study(false);
this.loseCount++;
this.gameCount++;
}
public void even() {
this.gameCount++;
}
public String toResultString() {
String result = "[" + this.name + ": ";
result += this.winCount + " wins, ";
result += this.loseCount + " losses]";
return result;
}
}