/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

***********************************************************************/

package gecco.client;

/**
 *  Represents the position of a Piece. The coordinates are given as doubles.
 *
 * @author     Andreas Enblom
 * @created    June 27, 2001
 */
public class Position {
    /**
     *  Description of the Field
     */
    public double x;
    /**
     *  Description of the Field
     */
    public double y;


    /**
     *  Initilizes a position at the origin (0,0);
     */
    public Position() {
        this(0, 0);
    }


    /**
     *  Initilizes a position with the same coordinates as the given position
     *  object.
     *
     * @param  p  Description of Parameter
     */
    public Position(Position p) {
        this(p.x, p.y);
    }


    /**
     *  Constructor for the Position object
     *
     * @param  x  Description of Parameter
     * @param  y  Description of Parameter
     */
    public Position(double x, double y) {
        this.x = x;
        this.y = y;
    }


    /**
     *  Sets the X attribute of the Position object
     *
     * @param  x  The new X value
     */
    public void setX(double x) {
        this.x = x;
    }


    /**
     *  Sets the Y attribute of the Position object
     *
     * @param  y  The new Y value
     */
    public void setY(double y) {
        this.y = y;
    }


    /**
     *  Gets the X attribute of the Position object
     *
     * @return    The X value
     */
    public double getX() {
        return x;
    }


    /**
     *  Gets the Y attribute of the Position object
     *
     * @return    The Y value
     */
    public double getY() {
        return y;
    }


    /**
     *  Description of the Method
     *
     * @param  dx  Description of Parameter
     * @param  dy  Description of Parameter
     */
    public void translate(double dx, double dy) {
        setX(getX() + dx);
        setY(getY() + dy);
    }


    /**
     *  Description of the Method
     *
     * @param  p  Description of Parameter
     * @return    Description of the Returned Value
     */
    public boolean equals(Position p) {
        if ((x == p.x) && (y == p.y)) {
            return true;
        } else {
            return false;
        }
    }
}
