Anthony Debucquoy a7a3e8b36e
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
DownDate to java 11
2023-05-04 22:12:13 +02:00

40 lines
819 B
Java

package school_project;
import java.io.Serializable;
/**
* This is used to represent a position/vector/... any ensemble of 2 elements that have to work together in
* a plan. This way we can use some basic operations over them.
*/
public class Vec2 implements Serializable {
public int x, y;
public Vec2() {
x = 0;
y = 0;
}
public Vec2(int x, int y ){
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Vec2) {
Vec2 vec = (Vec2) obj;
return this.x == vec.x && this.y == vec.y;
}
return false;
}
public Vec2 add(Vec2 o){
return new Vec2(x + o.x, y + o.y);
}
@Override
public String toString() {
return "("+x+","+y+")";
}
}