package Test;
public class test6 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Mypoint mypoint1 = new Mypoint(1,1);
Mypoint mypoint2 = new Mypoint(2,2);
double distance = Mypoint.getDistance(mypoint1, mypoint2);
System.out.println("这两个点的距离是:"+distance);
}
}
class Mypoint {
private int x = 0;
private int y = 0;
Mypoint(){
x = 0;
y = 0;
}
Mypoint(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 static double getDistance(Mypoint mypoint1,Mypoint mypoint2) {
double distance = Math.sqrt(Math.pow((mypoint1.getX()-mypoint2.getX()), 2)+Math.pow((mypoint1.getY()-mypoint2.getY()), 2));
return distance;
}
}