⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chessshi.java

📁 ajax chessajax chessajax chessajax chess
💻 JAVA
字号:
package chs;

public class ChessShi extends ChessItem {

	public ChessShi(String id, int x, int y) {
		super(id, x, y);
		// TODO Auto-generated constructor stub
	}

	public ChessShi(ChessBoard b, String id, int x, int y) {
		super(b, id, x, y);
		// TODO Auto-generated constructor stub
	}

	public boolean isOnDiag(int x, int y){
		int dx = Math.abs(this.x - x);
		int dy = Math.abs(this.y - y);
		return dx == dy && dy == 1;
	}

	public boolean moveTo(int x, int y) {
		if (!this.isOnDiag(x, y)) {
			System.err.println("not on a diag.");
			return false;
		}

		// 不在王宫里
		if (this.isInBase(x, y)) {
			System.err.println("move out of palace.");
			return false;
		}
		
		return true;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -