-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextReporter.java
40 lines (32 loc) · 1005 Bytes
/
TextReporter.java
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
/* Skeleton code copyright (C) 2008, 2022 Paul N. Hilfinger and the
* Regents of the University of California. Do not distribute this or any
* derivative work without permission. */
package ataxx;
import static ataxx.PieceColor.*;
/** An object that formats and sends messages and errors by printing them.
* @author P. N. Hilfinger
*/
class TextReporter implements Reporter {
@Override
public void announceWin(PieceColor side) {
if (side == EMPTY) {
msg("* Draw.");
} else {
msg("* %s wins.", side.toString());
}
}
@Override
public void announceMove(Move move, PieceColor player) {
msg("* %s moves %s.", player, move);
}
@Override
public void msg(String format, Object... args) {
System.out.printf(format, args);
System.out.println();
}
@Override
public void err(String format, Object... args) {
System.err.printf(format, args);
System.err.println();
}
}