algorithms-for-computing-li.../LinearRegressionTool/src/main/java/model/Point.java

108 lines
2.0 KiB
Java

package 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<Point> {
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() == 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 other zu vergleichernder Punkt
* @return <code>true</code> falls die Punkte gleich sind
*/
public boolean equals(Point other) {
if (other.getX() == this.getX() && other.getY() == this.getY()) {
return true;
} else {
return false;
}
}
/**
* @return id des Punkts
*/
public String getId() {
return id;
}
/**
* @param id id des Punkts
*/
public void setId(String id) {
this.id = id;
}
}