package paz1a.practicals.task9;
public class Bod {
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() {
}
public Bod(double x, double y) {
this.x = x;
this.y = y;
}
public String toString() {
return ("[" + this.x + ", " + this.y + "]");
}
public void nastav(double x, double y) {
this.x = x;
this.y = y;
}
public void nastav(Bod bod) {
this.x = bod.getX();
this.y = bod.getY();
}
public boolean rovnakeSuradnice(Bod bod) {
if(this.x == bod.getX() && this.y == bod.getY()){
return true;
}
return false;
}
public double vzdialenostK(double x, double y) {
double r = Math.sqrt((this.x - x) * (this.x - x) + (this.y - y) * (this.y - y));
return r;
}
public double vzdialenostK(Bod bod) {
return vzdialenostK(bod.getX(), bod.getY());
}
public void posunO(double dx, double dy) {
this.x += dx;
this.y += dy;
// nastav(this.x + dx, this.y + dy)
}
public Bod posunutyBod(double dx, double dy) {
Bod novy = new Bod(this.x, this.y);
novy.posunO(dx, dy);
return novy;
}
}