All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.dvberkel.box.Translation Maven / Gradle / Ivy

The newest version!
package nl.dvberkel.box;

public class Translation {
    public final int dx;
    public final int dy;

    public Translation(int dx, int dy) {
        this.dx = dx;
        this.dy = dy;
    }

    public Translation translateBy(Translation that) {
        return new Translation(this.dx + that.dx, this.dy + that.dy);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Translation that = (Translation) o;

        if (dx != that.dx) return false;
        return dy == that.dy;

    }

    @Override
    public int hashCode() {
        int result = dx;
        result = 31 * result + dy;
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy