Open app on empty maze and improve load/save #23
No files matched your search
+35
-7
@@ -84,16 +84,44 @@ public class Maze
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Maze emptySquareMaze() {
|
public static Maze emptyMaze(int dimension) {
|
||||||
int dimensionX = 10;
|
Box[][] maze = new Box[dimension][dimension];
|
||||||
int dimensionY = 10;
|
for (int line = 0; line < dimension; line++) {
|
||||||
Box[][] maze = new Box[dimensionY][dimensionX];
|
for (int row = 0; row < dimension; row++) {
|
||||||
for (int line = 0; line < dimensionY; line++) {
|
|
||||||
for (int row = 0; row < dimensionX; row++) {
|
|
||||||
maze[line][row] = new EBox("E", line, row, null);
|
maze[line][row] = new EBox("E", line, row, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Maze(dimensionY, dimensionX, maze);
|
return new Maze(dimension, dimension, maze);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Maze emptyMaze(int numberOfLines, int numberOfRows) {
|
||||||
|
Box[][] maze = new Box[numberOfLines][numberOfRows];
|
||||||
|
for (int line = 0; line < numberOfLines; line++) {
|
||||||
|
for (int row = 0; row < numberOfRows; row++) {
|
||||||
|
maze[line][row] = new EBox("E", line, row, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Maze(numberOfLines, numberOfRows, maze);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Maze wallMaze(int dimension) {
|
||||||
|
Box[][] maze = new Box[dimension][dimension];
|
||||||
|
for (int line = 0; line < dimension; line++) {
|
||||||
|
for (int row = 0; row < dimension; row++) {
|
||||||
|
maze[line][row] = new WBox("W", line, row, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Maze(dimension, dimension, maze);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Maze wallMaze(int numberOfLines, int numberOfRows) {
|
||||||
|
Box[][] maze = new Box[numberOfLines][numberOfRows];
|
||||||
|
for (int line = 0; line < numberOfLines; line++) {
|
||||||
|
for (int row = 0; row < numberOfRows; row++) {
|
||||||
|
maze[line][row] = new WBox("W", line, row, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Maze(numberOfLines, numberOfRows, maze);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCost(VertexInterface start, VertexInterface end) {
|
public int getCost(VertexInterface start, VertexInterface end) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class MazeAppModel extends Observable {
|
|||||||
private Boolean modified = false;
|
private Boolean modified = false;
|
||||||
|
|
||||||
public MazeAppModel() {
|
public MazeAppModel() {
|
||||||
maze = new Maze(Maze.emptySquareMaze());
|
maze = new Maze(Maze.emptyMaze(10));
|
||||||
departure = maze.getDeparture();
|
departure = maze.getDeparture();
|
||||||
arrival = maze.getArrival();
|
arrival = maze.getArrival();
|
||||||
boxList = maze.getVertexes();
|
boxList = maze.getVertexes();
|
||||||
|
|||||||
Reference in new issue
Block a user