Subato

equals auf Vertex

package name.panitz.oose;

public class Vertex {
  double x;
  double y;

  public Vertex(double x, double y) {
    super();
    this.x = x;
    this.y = y;
  }
  @Override
  public String toString() {
    return "("+x+","+y+")";
  }
  @Override
  public boolean equals(Object obj) {
    if (obj==null) return false;
    if (!obj.getClass().equals(Vertex.class)) return false;
    Vertex that = (Vertex)obj;
    return Math.abs(that.x-this.x)<=1 &&  Math.abs(that.y-this.y)<=1;
  }
}