/**
 * A simple, two-dimensional vector.
 * 
 * @author Martin Schend, Jannis Andrija Schnitzer
 * @version 2011-01-20
 */

public class Vector
{
    protected double x;
    protected double y;
   
    public Vector(double xValue, double yValue)
    {
        x = xValue;
        y = yValue;
    }
    public Vector(int xV, int yV)
    {
        this((double) xV, (double) yV);
    }
    public Vector(Vector v)
    {
        this(v.getX(), v.getY());
    }
    
    public double getX()
    {
        return x;
    }
    public void setX(double xValue)
    {
        x = xValue;
    }
    
    public double getY()
    {
        return y;
    }
    public void setY(double yValue)
    {
        y = yValue;
    }
    
    public void set(double xV, double yV)
    {
        x = xV;
        y = yV;
    }
    
    /**
     * Absolute value of the vector, a. k. a. length of its arrows.
     */
    public double length()
    {
        return (Math.sqrt(x*x+y*y));
    }
    
    /**
     * Add a vector to this vector.
     */
    public void add(Vector vectorToAdd)
    {
        x = x+vectorToAdd.getX();
        y = y+vectorToAdd.getY();
    }
}
