/*
* Scrabaid
*
* Revisions:
*
* 18/05/2001 lc - v1.0 release
*
* ----------------------------------------------------------------------------
*
* Scrabaid version 1.0, Copyright 2001 Linus Chang
* Scrabaid comes with ABSOLUTELY NO WARRANTY; for details, view the LICENCE
* file included with this distribution. This is free software, and you are
* welcome to redistribute it under certain conditions; view the LICENCE
* file for details.
*/


class ScrabaidMatch implements Comparable {
	public int startingPosition;
	public Pattern pattern;
	public Word word;
	public int row;
	public int col;
	public int score;
	public int numCharsUsed;
	public int compareTo(Object o) {
		ScrabaidMatch sm = (ScrabaidMatch) o;
		if (score != sm.score)
			return score - sm.score;
		else if (word.getString().compareTo(sm.word.getString()) != 0)
			return word.getString().compareTo(sm.word.getString());
		else if (row != sm.row)
			return row - sm.row;
		else if (col != sm.col)
			return col - sm.col;
		else if (startingPosition != sm.startingPosition)
			return startingPosition - sm.startingPosition;
		else
			return 0;
	}
	ScrabaidMatch(Pattern p, Word w) {
		pattern = p;
		word = w;
		startingPosition = -1;
		row = -1;
		col = -1;
		numCharsUsed = -1;
		score = 0;
	}
	ScrabaidMatch(ScrabaidMatch orig) {
		startingPosition = orig.startingPosition;
		pattern = orig.pattern;
		word = orig.word;
		row = orig.row;
		col = orig.col;
		score = orig.score;
		numCharsUsed = orig.numCharsUsed;
	}
	ScrabaidMatch(Pattern p, Word w, int n) {
		pattern = p;
		word = w;
		startingPosition = -1;
		row = -1;
		col = -1;
		numCharsUsed = n;
		score = 0;
	}
	public String toString() {
		String s = "Word " + word + ", Pattern " + pattern;
		if (startingPosition != -1)
			s = s + ", Starting position " + startingPosition;
		if (row != -1)
			s = s + ", row " + row;
		if (col != -1)
			s = s + ", column " + col;
		return s;
	}
}


