
public class Move {
	//source and dest coordinates
	int sourceIndex;
	int destIndex;

	public Move(int sourceIndex, int destIndex) {
		this.sourceIndex = sourceIndex;
		this.destIndex = destIndex;
	}

	public Move(int sourceColumn, int sourceRow, int destColumn, int destRow) {
		sourceIndex = sourceRow * 12 + sourceColumn + 2 + 12*2;
		destIndex = destRow * 12 + destColumn + 2 + 12*2;
	}

	public int getSourceIndex() {
		return sourceIndex;
	}

	public int getDestIndex() {
		return destIndex;
	}

	public int getSourceRow() {
		return sourceIndex / 12 - 2;
	}

	public int getSourceCol() {
		return sourceIndex % 12 - 2;
	}

	public int getDestRow() {
		return destIndex / 12 - 2;

	}

	public int getDestCol() {
		return destIndex % 12 - 2;
	}

	private String letterFor(int col) {
		return "abcdefgh".substring(col, col+1);
	}

	//returns something like e2-e4
	public String toString() {
		return letterFor(getSourceCol())+(getSourceRow()+1) + "-" + letterFor(getDestCol())+(getDestRow()+1);
	}

	public boolean equals(Object obj) {
		if (obj instanceof Move) {
			Move move = (Move)obj;
			return (move.sourceIndex == sourceIndex && move.destIndex == destIndex);
		}
		else {
			return false; //not even a move object
		}
	}

}
