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 {
dot 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) {
点 p1 = 新点 Point(2, 3);
点 p2 = 新点 (5, 8);
行 Straight = 新直线 (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
点(2, 3)和点(5, 8)之间的距离: 2.23606797749979
Please disable your ad blocker and refresh the window to use this website.