📄 mazespace.java
字号:
package mazeImplementation;// -----------------------------------------------// Programming 2 -- Semester 2, 2007// Maze Engine implementation// Peter Tilmanis, 8 August 2007// -----------------------------------------------// Maze space class// -----------------------------------------------import java.util.*;public class MazeSpace{ private HashMap <MazeRef,Room>space; private MazeRef limits; private MazeRef start; private MazeRef finish; public MazeSpace(MazeRef size) { space = new HashMap<MazeRef,Room>(); limits = size; start = new MazeRef(-1,-1,-1); finish = new MazeRef(-1,-1,-1); } public boolean isValidReference(MazeRef in) { if ( (in.getX() < 0) || (in.getX() >= limits.getX()) || (in.getX() < 0) || (in.getY() >= limits.getY()) || (in.getX() < 0) || (in.getZ() >= limits.getZ()) ) return false; else return true; } public boolean roomExists(MazeRef in) { return space.containsKey(in); } public boolean addRoom(Room in) { if (!isValidReference(in.getLocation())) return false; if (roomExists(in.getLocation())) return false; space.put(in.getLocation(), in); return true; } public Room getRoom(MazeRef in) { return space.get(in); } public Room[] getAllRooms() { return space.values().toArray(new Room[0]); } public boolean setStartPoint(MazeRef loc) { if (isValidReference(loc) && roomExists(loc) && !loc.equals(finish)) { start = loc; return true; } else return false; } public boolean setFinishPoint(MazeRef loc) { if (isValidReference(loc) && roomExists(loc) && !loc.equals(start)) { finish = loc; return true; } else return false; } public MazeRef getStartPoint() { return start; } public MazeRef getFinishPoint() { return finish; } public MazeRef getMazeSize() { return limits; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -