/*
 * Position.java
 *
 * Created on February 22, 2002, 9:49 AM
 */
import java.util.*;
/**
 *
 * @author  David Matuszek
 * @version 2
 */
public class Position implements Comparable {

    private int row;
    private int column;
    
    /** Creates new Position */
    public Position(int row, int column) {
        this.row = row;
        this.column = column;
    }

    /**
     * Tests whether two positions are equal.
     *
     * @param obj any object.
     * @return true if the argument equals this object.
     */
    public boolean equals(java.lang.Object obj) {
        System.out.println("Testing equality of " + this + " and " + obj);
        if (obj instanceof Position) {
            Position that = (Position)obj;
            return (this.row == that.row && this.column == that.column);
        }
        else return false;
    }
    
    /**
     * Computes a hash code for this object.
     */
    public int hashCode() { return 1000 * row + column; }
    
    /**
     * Compares this object with the specified object for order. Returns
     * a negative integer, zero, or a positive integer as this object is
     * less than, equal to, or greater than the specified object.
     *
     * @param obj The object to be compared.
     * @return A negative integer, zero, or a positive integer as this
     * object is less than, equal to, or greater than the specified object.
     * @throws ClassCastException When the input argument is not a Position.
     */
    public int compareTo(Object obj) {
        Position that = (Position)obj;
        if (this.row != that.row) return this.row - that.row;
        else return this.column - that.column;
    }
}

