我写了一个类,现在我正在尝试对其进行测试,但在我的类测试中出现错误,上面写着“CylinderTest.java:9: getHeight() in Cylinder cannot be applied to (double)”
这是我的课程的代码:
public class Cylinder
private double Radius;
private double Height;
public final static double Pi = 3.14159;
// constructor
public Cylinder()
{
Radius = 0.0;{
Height = 0.0;
}
// getRaduis method
public double getRadius()
{
return Radius;
}
// getHeight method
public double getHeight()
{
return Height;
}
// setRadius method
public void setRadius(double r)
{
Radius = r;
}
// setHeight method
public void setHeight(double h)
{
Height = h;
}
// getSurfaceArea
public double getBaseArea(double BaseArea)
{
BaseArea = Radius * Radius * Pi;
return BaseArea;
}
// getVolume
public double getVolume(double BaseArea, double Volume)
{
Volume = BaseArea * Height;
return Volume;
}
// Print
//System.out.println("The volume of the cylinder is " +Volume);
}
这是classTest的代码:
public class CylinderTest {
public static void main(String[] args)
{
Cylinder cylinderA = new Cylinder();
cylinderA.getRadius(3.5);
cylinderA.getHeight(4.5);
System.out.println(cylinderA.getVolume());
}
}
我编写的原始圆柱体类编译良好当我尝试编译 classTest 时遇到问题。任何帮助将不胜感激。