Батончик•Мейрам
public class Point {
public int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public void distance(){
System.out.println(getX()-getY());
}
}
Тут лучше так: private int x, y; дистанцию нужно наверно между двумя точками определять? тогда будет что-то такое:
public class Point {
private int x, y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public double distanceTo(Point point){
double distanse = Math.pow(Math.pow((x - point.getX()), 2) + Math.pow((y - point.getY()), 2), 0.5);
return distanse;
}
}