public class Point {
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 class Right {
точка p1, p2;
публичное право (точка p1, точка p2){
this.p1=p1;
this.p2=p2;
}
double length(){
return p1.distance(p2);
}
}
double distance(Point p){
return Math.sqrt(((p.getX()-this.getX()) + (p.getY()-this.getY()));
}
public class Main {
public static void main(String[] args) {
Point p1 = new Point(2, 3);
Точка p2 = новая Точка(5, 8);
строка Стрит = новый стрит (p1, p2);
System.out.println(Right.length());
Точка p3 = новая точка(7, 3);
System.out.println("расстояние между точкой("+p1.getX()+", "+p1.getY()+
") и точкой("+p2.getX()+", "+p2.getY()+": "+p1.distance(p3));
}
}
2.8284271247461903
Расстояние между point(2, 3) и point(5, 8): 2.23606797749979
Please disable your ad blocker and refresh the window to use this website.