📄 chessbing.java
字号:
package chs;
public class ChessBing extends ChessItem {
public ChessBing(String id, int x, int y) {
super(id, x, y);
// TODO Auto-generated constructor stub
}
public ChessBing(ChessBoard b, String id, int x, int y) {
super(b, id, x, y);
// TODO Auto-generated constructor stub
}
public boolean isBackward(int y){
if(id.charAt(0) == 'r'){
return this.y > y;
}else{
return this.y < y;
}
}
public boolean isCrab(int x){
return this.x != x;
}
public boolean canCrab(){
if(id.charAt(0) == 'r'){
return this.y >= 6;
}else{
return this.y <= 5;
}
}
public boolean moveTo(int x, int y){
if(!this.isOnStep(x, y)){
System.err.println("move over 1 step.");
return false;
}
if(this.isBackward( y)){
System.err.println("backward move for bing.");
return false;
}
// 横着走了
if(!this.canCrab() && this.isCrab(x)){
System.err.println("crab move on self kingdom.");
return false;
}
return true;
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -