-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_Grid_Generation.java
More file actions
74 lines (68 loc) · 2.45 KB
/
Copy pathTest_Grid_Generation.java
File metadata and controls
74 lines (68 loc) · 2.45 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
package gameboard;
//Class used to test the grid
public class Test_Grid_Generation {
public static void main(String[] args) {
try {
//Create the grid
Grid grid = Grid.generateGrid(9, 9, new Cell(0, 0, CellEntityType.PLAYER, false, false));
System.out.println(grid);
Cell startingCell = grid.getStartingCell();
System.out.println("Starting Cell: " + startingCell.getOx() + " " + startingCell.getOy());
//Move in all 4 directions as much as possible
while (true) {
try {
grid.goNorth();
System.out.println("Went North");
}
catch (Exception e) {
System.out.println(e.getMessage());
break;
}
}
System.out.println(grid);
while (true) {
try {
grid.goEast();
System.out.println("Went East");
}
catch (Exception e) {
System.out.println(e.getMessage());
break;
}
}
System.out.println(grid);
while (true) {
try {
grid.goSouth();
System.out.println("Went South");
}
catch (Exception e) {
System.out.println(e.getMessage());
break;
}
}
System.out.println(grid);
while (true) {
try {
grid.goWest();
System.out.println("Went West");
}
catch (Exception e) {
System.out.println(e.getMessage());
break;
}
}
System.out.println(grid);
//Prints out each cell's location and type to help debug
for (int i = 0; i < grid.getLength(); i++) {
for (int j = 0; j < grid.getWith(); j++) {
Cell cell = grid.getCell(i, j);
String res = cell.cellType + " Ox: " + cell.Ox + " Oy: " + cell.Oy;
System.out.println(res);
}
}
} catch (Exception e) {
System.out.println("Unexpected Exception during test: " + e.getMessage());
}
}
}