当前位置: 代码迷 >> Java相关 >> 为什么TestCylinder4.java在运行时会出现如下问题
  详细解决方案

为什么TestCylinder4.java在运行时会出现如下问题

热度:235   发布时间:2006-12-06 18:36:47.0
为什么TestCylinder4.java在运行时会出现如下问题

为什么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:";
}
}

搜索更多相关的解决方案: 时会  czg  abstract  public  

----------------解决方案--------------------------------------------------------
看不见图。。。
----------------解决方案--------------------------------------------------------
运行一下就可以了,望解决,急!!!!!!!!!!!!!!!!!

----------------解决方案--------------------------------------------------------
你把错误信息发上来看
----------------解决方案--------------------------------------------------------
...楼主以后不要这样发了   看的眼都花了  
发问题要把你的错误  异常之类的信息帖上来
----------------解决方案--------------------------------------------------------
  相关解决方案