package Test;public class Point { private double x; private double y; private double z; public Point(double x,double y,double z) { this.x=x; this.y=y; this.z=z; } public double getX() { return x; } public void setX(double x) { this.x = x; } public double getY() { return y; } public void setY(double y) { this.y = y; } public double getZ() { return z; } public void setZ(double z) { this.z = z; } public double getDistance(Point p){ return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)+(z-p.z)*(z-p.z); }}public class TestPoint{ //这里报错 public static void main(String[] args) { Point p=new Point(1.0, 2.0, 3.0); Point p1=new Point(0.0, 0.0, 0.0); System.out.println(p.getDistance(p1)); p.setX(5.0); System.out.println(p.getDistance(new Point(1.0, 1.0, 1.0))); }}
添加回答
举报
0/150
提交
取消