/**
 *
 * @author Ryan J. Marcotte
 */

package game;

public class Square implements Comparable<Square>
{
    final int NUM_NEIGHBORS = 8;
    int intLocation;
    Square neighbors[] = new Square[NUM_NEIGHBORS];
    ChessPiece occupant;

    public Square(int intLocation)
    {
        this.intLocation = intLocation;
        occupant = null;
    }

    protected Square copySquare()
    {
        Square copiedSquare = new Square(intLocation);
        copiedSquare.setOccupant(occupant);
        return copiedSquare;
    }

    @Override
    public int compareTo(Square otherSquare)
    {
        int otherIntLocation = otherSquare.getIntLocation();

        if (intLocation < otherIntLocation)
            return -1;
        else if (intLocation == otherIntLocation)
            return 0;
        else
            return 1;
    }

    protected Square getNeighbor(int direction)
    {
        return neighbors[direction];
    }

    protected ChessPiece getOccupant()
    {
        return occupant;
    }

    public int getIntLocation()
    {
        return intLocation;
    }

    public boolean isOccupied()
    {
        return occupant != null;
    }

    protected void setNeighbor(Square neighbor, int direction)
    {
        neighbors[direction] = neighbor;
    }

    protected void setOccupant(ChessPiece occupant)
    {
        this.occupant = occupant;
    }
}

@@ -1368,11 +1368,110 @@
 t;%0A    %7D
+%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        return %22Square at %22 + intLocation;%0A    %7D
 %0A%7D%0A

add toString for Square