package sk.upjs.paz.task9;
public class Bod {
private double x;
private double y;
public Bod() {
}
public Bod(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return this.x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return this.y;
}
public void setY(double y) {
this.y = y;
}
public String toString() {
return "[" + x + ", " + y + "]";
}
public void nastav(double x, double y) {
this.x = x;
this.y = y;
}
public boolean rovnakeSuradnice(Bod bod) {
return this.x == bod.getX() && this.y == bod.getY();
// if (this.x == bod.getX() && this.y == bod.getY())
// return true;
// return false;
}
public double vzdialenostK(double x, double y) {
double dx = this.x - x;
double dy = this.y - 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) {
x = x + dx;
y = y + dy;
// nastav(x + dx, y + dy);
}
public void nastav(Bod bod) {
this.x = bod.getX();
this.y = bod.getY();
}
public Bod posunutyBod(double dx, double dy) {
Bod b = new Bod();
b.nastav(this);
b.posunO(dx, dy);
return b;
}
}