package sk.upjs.paz1a.cvicenie9;
public class Bod extends Object {
private double x;
private double y;
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public Bod() {
this.x = 0;
this.y = 0;
}
public Bod(double x, double y) {
this.x = x;
this.y = y;
}
public String toString() {
return "[" + x + ", " + y + "]";
}
public void nastav(double x, double y) {
setX(x);
setY(y);
}
public void nastav(Bod bod) {
nastav(bod.getX(), bod.getY());
}
public boolean rovnakeSuradnice(Bod bod) {
return (getX() == bod.getX()) && (getY() == bod.getY());
}
public double vzdialenostK(double x, double y) {
double dx = getX() - x;
double dy = getY() - y;
return Math.sqrt(dx * dx + dy * dy);
}
public double vzdialenostK(Bod bod) {
return vzdialenostK(bod.getX(), bod.getY());
}
public void posunO(double dx, double dy) {
nastav(getX() + dx, getY() + dy);
}
public Bod posunutyBod(double dx, double dy) {
return new Bod(getX() + dx, getY() + dy);
}
}