-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIPlayer.java
More file actions
46 lines (37 loc) · 1.04 KB
/
Copy pathGUIPlayer.java
File metadata and controls
46 lines (37 loc) · 1.04 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
package amazons;
/** A Player that takes input from a GUI.
* @author Khang
*/
class GUIPlayer extends Player implements Reporter {
/** A new GUIPlayer that takes moves and commands from GUI. */
GUIPlayer(GUI gui) {
this(null, null, gui);
}
/** A new GUIPlayer playing PIECE under control of CONTROLLER, taking
* moves and commands from GUI. */
GUIPlayer(Piece piece, Controller controller, GUI gui) {
super(piece, controller);
_gui = gui;
}
@Override
Player create(Piece piece, Controller controller) {
return new GUIPlayer(piece, controller, _gui);
}
@Override
String myMove() {
return _gui.readCommand();
}
@Override
public void reportError(String fmt, Object... args) {
_gui.reportError(fmt, args);
}
@Override
public void reportNote(String fmt, Object... args) {
_gui.reportNote(fmt, args);
}
@Override
public void reportMove(Move unused) {
}
/** The GUI I use for input. */
private GUI _gui;
}