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

📄 virtualchessboard.java

📁 一款JAVA款的跳棋
💻 JAVA
字号:
package org.yushang.jumpchess.pkg;

import java.util.Vector;

import org.yushang.jumpchess.pub.Position;
import org.yushang.jumpchess.strategy.Step;

public class VirtualChessBoard extends ChessBoard {
	private Vector chesses = new Vector();
	private Vector positions = new Vector();
	private Vector oldPositions = new Vector();
	private ChessBoard chessBoard = null;
	
	public VirtualChessBoard(ChessBoard chessBoard) {
		this(chessBoard, null);
	}
	
	public VirtualChessBoard (ChessBoard chessBoard, Step step) { 
		this.chessBoard = chessBoard;
		if (step != null) {
			this.Go(step.chess, step.position);
		}
	}

	public Chess getChess(Position position) {
		int index = positions.indexOf(position);
		if (index != -1) {
			return (Chess) chesses.get(index);
		}
		if (oldPositions.indexOf(position) != -1){
			return null;
		}
		
		return chessBoard.getChess(position);
	}

	public Chess getChess(int index) {
		return chessBoard.getChess(index);
	}

	public int getChessCount() {
		return chessBoard.getChessCount();
	}

	public Position getPosition(Chess chess) {
		int index = chesses.indexOf(chess);
		if (index != -1) {
			return (Position) positions.get(index);
		}
		return chessBoard.getPosition(chess);
	}
	
	public Position getPosition(int index) {		
		return getPosition(getChess(index));
	}

	public void Go(Chess chess, Position chessPosition) {
		int index = chesses.indexOf(chess);
		if (index != -1) {
			((Position) positions.get(index)).Set(chessPosition.getx(),
					chessPosition.gety());
		} else {
			chesses.add(chess);
			positions.add(new Position(chessPosition));
			oldPositions.add(new Position(chessBoard.getPosition(chess)));
		}		
	}	
	

}

⌨️ 快捷键说明

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