-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOXOTester.java
More file actions
49 lines (45 loc) · 1.55 KB
/
OXOTester.java
File metadata and controls
49 lines (45 loc) · 1.55 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 OXOExceptions.OXOMoveException;
public class OXOTester
{
public OXOTester()
{
}
public static void main(String args[])
{
boolean assertionsEnabled = false;
assert(assertionsEnabled = true);
if (assertionsEnabled) {
testInput();
System.out.println("SUCCESS: All tests passed !!!");
}
else {
System.out.println("You MUST run java with assertions enabled (-ea) to test your program !");
}
}
public static void testInput()
{
OXOModel model = new OXOModel(3,3,3);
model.addPlayer(new OXOPlayer('X'));
model.addPlayer(new OXOPlayer('O'));
OXOController controller = new OXOController(model);
try{
controller.handleIncomingCommand("a1");
controller.handleIncomingCommand("a2");
controller.handleIncomingCommand("a3");
controller.handleIncomingCommand("b1");
controller.handleIncomingCommand("b2");
controller.handleIncomingCommand("b3");
model.setWinThreshold(4);
model.addPlayer(new OXOPlayer('Z'));
controller.handleIncomingCommand("c1");
controller.handleIncomingCommand("c2");
controller.handleIncomingCommand("c3");
}
catch (OXOMoveException e){
System.out.println(e);
}
assert(model.getWinner() == null);
assert(model.getPlayerByNumber(2).getPlayingLetter() == 'Z');
assert(model.getCellOwner(2,2).getPlayingLetter() == 'Z');
}
}