package de.wwwu.awolf.model; /** * Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden. * * @Author: Armin Wolf * @Email: a_wolf28@uni-muenster.de * @Date: 28.05.2017. */ public class Point implements Comparable { private Double x; private Double y; private String id; /** * Konstruktor * * @param x x-Koordiante * @param y y-Koordiante */ public Point(Double x, Double y) { this.x = x; this.y = y; } /** * Konstruktor * * @param x x-Koordiante * @param y y-Koordiante * @param id id des Punkts */ public Point(Double x, Double y, String id) { this.x = x; this.y = y; this.id = id; } /** * @return x-Koordinate des Punkts */ public Double getX() { return x; } /** * @param x x-Koordinate des Punkts */ public void setX(Double x) { this.x = x; } /** * @return y-Koordinate des Punkts */ public Double getY() { return y; } /** * @param y y-Koordinate des Punkts */ public void setY(Double y) { this.y = y; } @Override public int compareTo(Point o) { if (this.getX().equals(o.getX())) { if (this.getY() <= o.getY()) { return -1; } else { return 1; } } else if (this.getX() < o.getX()) { return -1; } else { return 1; } } /** * Vergleich zweier Punkte * * @param obj zu vergleichernder Punkt * @return true falls die Punkte gleich sind */ @Override public boolean equals(Object obj) { if (obj instanceof Point) { Point other = (Point) obj; return other.getX().equals(this.getX()) && other.getY().equals(this.getY()); } else { return super.equals(obj); } } @Override public int hashCode() { return super.hashCode() + this.getX().hashCode() + this.getY().hashCode(); } /** * @return id des Punkts */ public String getId() { return id; } /** * @param id id des Punkts */ public void setId(String id) { this.id = id; } }