二十分钟之内,考试题!

二十分钟之内,考试题!求求求
2025-05-13 05:11:33
推荐回答(1个)
回答1:

public class CCPoint {
double x1;
double y1;

public CCPoint() {
}

public CCPoint(double x1, double y1) {
this.x1 = x1;
this.y1 = y1;
}

public double getX1() {
return x1;
}

public double getY1() {
return y1;
}

public double distance1(CCPoint p) {
return Math.sqrt(Math.abs((p.getX1() - this.getX1()) * (p.getX1() - this.getX1())
+ (p.getY1() - this.getY1()) * (p.getY1() - this.getY1())));
}
}

public class CCPointTest {
public static void main(String[] args) {
CCPoint p1 = new CCPoint(1,1);
CCPoint p2 = new CCPoint(2,2);
System.out.println(p1.distance1(p2));
}
}