SimpleJavaEngine/src/main/java/speiger/src/coreengine/math/vector/ints/Vec2iMutable.java

65 lines
1.0 KiB
Java
Raw Normal View History

2021-08-27 06:07:15 +02:00
package speiger.src.coreengine.math.vector.ints;
import java.util.Objects;
public class Vec2iMutable implements Vec2i {
2021-08-27 06:07:15 +02:00
int x;
int y;
public Vec2iMutable() {}
2021-08-27 06:07:15 +02:00
public Vec2iMutable(int value) {
2021-08-27 06:07:15 +02:00
x = value;
y = value;
}
public Vec2iMutable(int x, int y) {
2021-08-27 06:07:15 +02:00
this.x = x;
this.y = y;
}
@Override
public boolean isMutable() { return true; }
2021-08-27 06:07:15 +02:00
@Override
public int getX() { return x; }
@Override
public int getY() { return y; }
2021-08-27 06:07:15 +02:00
@Override
public Vec2i setX(int x) {
2021-08-27 06:07:15 +02:00
this.x = x;
return this;
}
@Override
public Vec2i setY(int y) {
2021-08-27 06:07:15 +02:00
this.y = y;
return this;
}
@Override
public Vec2i copy() { return Vec2i.mutable(this); }
2021-08-27 06:07:15 +02:00
@Override
public Vec2i set(int x, int y) {
2021-08-27 06:07:15 +02:00
this.x = x;
this.y = y;
return this;
}
@Override
public int hashCode() { return Objects.hash(x, y); }
2021-08-27 06:07:15 +02:00
@Override
public boolean equals(Object obj) {
if(obj instanceof Vec2i) {
2021-08-27 06:07:15 +02:00
Vec2i vec = (Vec2i)obj;
return vec.getX() == x && vec.getY() == y;
}
return false;
}
2021-08-27 06:07:15 +02:00
@Override
public String toString() { return "Vec2i[x="+x+", y="+y+"]"; }
2021-08-27 06:07:15 +02:00
}