package speiger.src.coreengine.math.vector.shorts;

import java.util.Objects;

public class Vec2sMutable implements Vec2s {
	short x;
	short y;
	
	public Vec2sMutable() {}
	
	public Vec2sMutable(short value) {
		x = value;
		y = value;
	}
	
	public Vec2sMutable(short x, short y) {
		this.x = x;
		this.y = y;
	}
	
	@Override
	public boolean isMutable() { return true; }
	@Override
	public short x() { return x; }
	@Override
	public short y() { return y; }
	
	@Override
	public Vec2s x(short x) {
		this.x = x;
		return this;
	}
	
	@Override
	public Vec2s y(short y) {
		this.y = y;
		return this;
	}
	
	@Override
	public Vec2s copy() { return Vec2s.mutable(this); }
	
	@Override
	public Vec2s set(short x, short y) {
		this.x = x;
		this.y = y;
		return this;
	}
	
	@Override
	public int hashCode() { return Objects.hash(x, y); }
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Vec2s) {
			Vec2s vec = (Vec2s)obj;
			return vec.x() == x && vec.y() == y;
		}
		return false;
	}
	
	@Override
	public String toString() { return "Vec2s[x="+x+", y="+y+"]"; }
}
