/**
 *  Vector 2D Class
 *  <p>
 *  This class describes 2d vectors, This is very helpfull in a 2d board game
 */
public class Vector2D {
	private int x, y;  // we will use cartesian coordinates

	/**
	* Constructor without parameters for Vector2D
	*/
	public Vector2D () {
		x = y = 0;
	}

	/**
	* Constructor with parameters for Vector2D
	* @param x x value for the vector
	* @param y y value for the vector
	*/
	public Vector2D (int x, int y) {
		this.x = x;
		this.y = y;
	}

	/**
	* Method to get the x value of the vector
	* @return x value
	*/
	public int getX(){
		return x;
	}

	/**
	* Method to get the y value of the vector
	* @return y value
	*/
	public int getY(){
		return y;
	}

	/**
	* Method to set the x value of the vector
	* @param x new value
	*/
	public void setX(int a){
		x = a;
	}

	/**
	* Method to set the y value of the vector
	* @param y new value
	*/
	public void setY(int b){
		y = b;
	}

	/**
	* Method to add two vectors
	* @param v Vector to add
	*/
	public Vector2D plus(Vector2D v) {
		if (v == null)
			return new Vector2D(x, y);
		return new Vector2D (x + v.x, y + v.y);
	}

	/**
	* Method to multiply a vector by a scalar
	* @param scalar scalar value
	*/
	public Vector2D times(int scalar) {
		return new Vector2D(x * scalar, y * scalar);
	}

	/**
	* Method to subtract two vectors
	* @param v Vector to subtract
	*/
	public Vector2D minus(Vector2D v) {
		if (v==null) return new Vector2D (x,y);
		else return new Vector2D(x - v.x, y - v.y);
	}
	
	public String toString() {
		return "Vector "+x+","+y;
	}
}