-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidate.java
More file actions
77 lines (58 loc) · 1.5 KB
/
Copy pathValidate.java
File metadata and controls
77 lines (58 loc) · 1.5 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import concurrentcube.Cube;
public class Validate {
private static final String EXPECTED =
"0000"
+ "0000"
+ "0000"
+ "1111"
+ "1115"
+ "1115"
+ "4444"
+ "1115"
+ "2222"
+ "2222"
+ "1115"
+ "2222"
+ "0333"
+ "0333"
+ "2222"
+ "0333"
+ "4444"
+ "4444"
+ "0333"
+ "4444"
+ "3333"
+ "5555"
+ "5555"
+ "5555";
private static void error(int code) {
System.out.println("ERROR " + code);
System.exit(code);
}
public static void main(String[] args) {
var counter = new Object() { int value = 0; };
Cube cube = new Cube(4,
(x, y) -> { ++counter.value; },
(x, y) -> { ++counter.value; },
() -> { ++counter.value; },
() -> { ++counter.value; }
);
try {
cube.rotate(2, 0);
cube.rotate(5, 1);
if (counter.value != 4) {
error(1);
}
String state = cube.show();
if (counter.value != 6) {
error(2);
}
if (!state.equals(EXPECTED)) {
error(3);
}
System.out.println("OK");
} catch (InterruptedException e) {
error(4);
}
}
}