C
chinaceleron
Unregistered / Unconfirmed
GUEST, unregistred user!
一个很简单的程序,但是编译不过去,请大家帮助!谢谢!
class Points
{
//Coordinates of the point
double x;
double y;
//Create a point from coordinates
Points(double xVal,double yVal)
{
x=xVal;
y=yVal;
}
//Create a point from another Point object
Points(final Points oldPoint)
{
x=oldPoint.x;
y=oldPoint.y;
}
//Move a point
void move(double xDelta,double yDelta)
{
//Parameter values are increments to the current coordinates
x+=xDelta;
y+=yDelta;
}
//Calculate the distance to another point
double distance(final Points aPoint)
{
return
Math.sqrt((x-aPoint.x)*(x-aPoint.x)+(y-aPoint.y)*(y-aPoint.y));
}
//Convert a point to a string
public String toString()
{
returndo
uble.toString();
}
}
编译后,总是提示以下错误信息。
---------- JavaC ----------
Points.java:42: Can´t make static reference to method java.lang.String toString() in class java.lang.Double.
returndo
uble.toString();
^
class Points
{
//Coordinates of the point
double x;
double y;
//Create a point from coordinates
Points(double xVal,double yVal)
{
x=xVal;
y=yVal;
}
//Create a point from another Point object
Points(final Points oldPoint)
{
x=oldPoint.x;
y=oldPoint.y;
}
//Move a point
void move(double xDelta,double yDelta)
{
//Parameter values are increments to the current coordinates
x+=xDelta;
y+=yDelta;
}
//Calculate the distance to another point
double distance(final Points aPoint)
{
return
Math.sqrt((x-aPoint.x)*(x-aPoint.x)+(y-aPoint.y)*(y-aPoint.y));
}
//Convert a point to a string
public String toString()
{
returndo
uble.toString();
}
}
编译后,总是提示以下错误信息。
---------- JavaC ----------
Points.java:42: Can´t make static reference to method java.lang.String toString() in class java.lang.Double.
returndo
uble.toString();
^