-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests.java
48 lines (42 loc) · 2.2 KB
/
Tests.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
41
42
43
44
45
46
47
48
package com.lyndseyjane.fourinarow;
public class Tests {
private static Color[] tie = new Color[] {
Color.RED, Color.RED, Color.RED, Color.BLUE, Color.RED, Color.RED, Color.RED,
Color.BLUE, Color.BLUE, Color.BLUE, Color.RED, Color.BLUE, Color.BLUE, Color.BLUE,
Color.RED, Color.RED, Color.RED, Color.BLUE, Color.RED, Color.RED, Color.RED,
Color.BLUE, Color.BLUE, Color.BLUE, Color.RED, Color.BLUE, Color.BLUE, Color.BLUE,
Color.RED, Color.RED, Color.RED, Color.BLUE, Color.RED, Color.RED, Color.RED,
Color.BLUE, Color.BLUE, Color.BLUE, Color.RED, Color.BLUE, Color.BLUE, Color.BLUE
};
private static Color[] easyBlueWin = new Color[] {
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.BLUE, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.BLUE, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.RED, Color.BLUE, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.RED, Color.BLUE, Color.RED, Color.RED, Color.EMPTY
};
private static Color[] easyRedWin = new Color[] {
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.RED, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.EMPTY, Color.RED, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.BLUE, Color.RED, Color.EMPTY, Color.EMPTY, Color.EMPTY,
Color.EMPTY, Color.EMPTY, Color.BLUE, Color.RED, Color.BLUE, Color.BLUE, Color.EMPTY
};
public static void test(GameBoard board, Color[] boardArrangement) {
board.clear();
board.draw();
for (int r = 0; r < 6; ++r) {
for (int c = 0; c < 7; ++c) {
board.setColor(r, c, boardArrangement[(r*7)+c]);
}
}
System.out.println("The winner is "+board.hasWon());
}
public static void runAllTests(GameBoard board) {
test(board, easyRedWin);
test(board, easyBlueWin);
test(board, tie);
}
}