package sk.upjs;
import java.awt.Color;
public class Bod {
private double x;
private double y;
private Color farba;
public Bod(double x, double y) {
this.x = x;
this.y = y;
}
public Bod(double x, double y, Color c) {
this.x = x;
this.y = y;
this.farba = c;
}
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 Color getFarba() {
return farba;
}
// public void setFarba(Color farba) {
// this.farba = farba;
// }
public String toString() {
String s = "";
s = s + "x: " + x + ",";
s = s + "y: " + y + ",";
if (farba != null)
s = s + "farba: " + "(" + farba.getRed() + "," + farba.getBlue()
+ "," + farba.getGreen() + ")";
return s;
}
void nastav(double x, double y) {
this.x = x;
this.y = y;
}
void nastav(Bod bod) {
// this.x = bod.getX();
// this.y = bod.getY();
this.nastav(x, y);
}
boolean rovnakeSuradnice(Bod bod) {
if ((this.x == bod.getX()) && (this.y == bod.getY()))
return true;
return false;
}
double vzdialenostK(double x, double y) {
double vzdialenost = Math.pow(Math.abs(this.getX() - x), 2)
+ Math.pow(Math.abs(this.getY() - y), 2);
vzdialenost = Math.sqrt(vzdialenost);
return vzdialenost;
}
double vzdialenostK(Bod bod) {
return this.vzdialenostK(bod.x, bod.y);
}
void posunO(double dx, double dy) {
this.x = x + dx;
this.y = y + dy;
}
Bod posunutyBod(double dx, double dy) {
return new Bod(x + dx, y + dy);
}
}