📄 chessma.java
字号:
package chs;
public class ChessMa extends ChessItem {
public ChessMa(ChessBoard b, String id, int x, int y) {
super(b, id, x, y);
}
public boolean isOnCross(int x, int y){
int dx = Math.abs(this.x - x);
int dy = Math.abs(this.y - y);
return dx != 0 && dy != 0 && (dx+dy) == 3;
}
public boolean moveTo(int x, int y){
if(!isOnCross(x, y)){
System.err.println("not on a cross.");
return false;
}
// 别腿了
ChessItem c = b.findItemAt(this.getCenterX(x), this.getCenterY(y));
if(null != c){
System.err.println("found block:" + c.getId());
return false;
}
return true;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -