📄 util.java
字号:
package cn.nasa;
import java.util.HashMap;
import java.util.Map;
public class Util {
private Direction N, S, W, E, X;
public Coordinate coordinate;
public Direction direction;
private int max_x, max_y;
Map<String, Direction> map = new HashMap<String, Direction>();
Util(int x, int y, String dir, int max_x, int max_y) {
coordinate = new Coordinate(x, y);
N = new Direction();
S = new Direction();
W = new Direction();
E = new Direction();
N.setLeft(W);
E.setLeft(N);
W.setLeft(S);
S.setLeft(E);
N.setRight(E);
E.setRight(S);
W.setRight(N);
S.setRight(W);
N.setX_offset(0);
S.setX_offset(0);
W.setX_offset(-1);
E.setX_offset(1);
N.setY_offset(1);
S.setY_offset(-1);
W.setY_offset(0);
E.setY_offset(0);
map.put("N", N);
map.put("S", S);
map.put("W", W);
map.put("E", E);
direction = map.get(dir);
this.max_x = max_x;
this.max_y = max_y;
}
public boolean check() throws Exception {
if (coordinate.getX_coordinate() < 0
|| coordinate.getX_coordinate() >= max_x
|| coordinate.getY_coordinate() < 0
|| coordinate.getY_coordinate() >= max_y) {
throw new Exception("error");
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -