为什么TestCylinder4.java在运行时会出现如下问题:如图
涉及以下程序:
package c.czg;
public interface Shape1
{
public abstract double area();
public abstract double volume();
public abstract String getName();
}
package c.czg;
import c.czg.Shape;
public class Point4 extends Object implements Shape1
{
protected int x,y;
public Point4()
{
setPoint( 0,0 );
}
public Point4( int xCoordinate,int yCoordinate )
{
setPoint( xCoordinate,yCoordinate );
}
public void setPoint( int xCoordinate,int yCoordinate )
{
x = xCoordinate;
y = yCoordinate;
}
public double getX()
{
return x;
}
public double getY()
{
return y;
}
public String toString()
{
return "[" + x + "," + y + "]";
}
public double area()
{
return 0.0;
}
public double volume()
{
return 0.0;
}
public String getName()
{
return "Point:";
}
}
package c.czg;
import c.czg.Point4;
public class Circle4 extends Point4
{
protected double radius;
public Circle4()
{
setRadius( 0.0 );
}
public Circle4( double circleRadius,int xCoordinate,int yCoordinate )
{
super( xCoordinate,yCoordinate );
setRadius( circleRadius );
}
public void setRadius( double circleRadius )
{
radius = ( circleRadius >= 0.0 ? circleRadius : 0.0 );
}
public double getRadius()
{
return radius;
}
public double area()
{
return Math.PI * radius * radius;
}
public String toString()
{
return "Center = " + super.toString() +
"; Radius = " + radius;
}
public double volume()
{
return 0.0;
}
public String getName()
{
return "Circle:";
}
}
package c.czg;
import c.czg.Circle4;
public class Cylinder4 extends Circle4
{
protected double height;
public Cylinder4()
{
setHeight(0.0);
}
public Cylinder4( double cylinderHeight,double cylinderRadius,int xCoordinate,int yCoordinate )
{
super( cylinderRadius,xCoordinate,yCoordinate );
setHeight( cylinderHeight );
}
public void setHeight( double cylinderHeight )
{
height = ( cylinderHeight >= 0.0 ? cylinderHeight : 0.0 );
}
public double getHeight()
{
return height;
}
public double area()
{
return 2 * super.area() + Math.PI * radius * height;
}
public double volume()
{
return super.area() * height;
}
public String toString()
{
return super.toString() + "; Height = " + height;
}
public String getName()
{
return "Cylinder:";
}
}