回 帖 发 新 帖 刷新版面

主题:debug


class point {
    private double x;
    private double y;
    private double z;
    
    point(double -x,double -y,double -z) {      编译的时候总是显示则个构造方法
        x=-x;                          有问题·····怎么回事呀??
        y=-y;
        z=-z;
        }
    
    public void getx(double  x){
        x=x;
    }
    
    public void gety(double  y){
        y=y;
    }
    
    public void getz(double  z){
        z=z;
  }
  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 TextPoint {
  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)));    这个输出也有问
}                                                                 题!!!
    }
    
    我用JCreator 编译的

回复列表 (共2个回复)

沙发

point(double -x,double -y,double -z) {      
        x=-x;                          
        y=-y;
        z=-z;
        }

改成
 point(double x,double y,double z) {      
        x=-x;                          
        y=-y;
        z=-z;
        }
    
试试

板凳

System.out.println(p.getDistance(new point(1.0;1.0;1.0)));
point里面的那些";"改成","就好了

我来回复

您尚未登录,请登录后再回复。点此登录或注册