在TestCylinder类中创建Cylinder类的对象,设置圆柱的底面半径和高,并输出圆柱的体积
Circlele
-radius:double
Circle():构造方法,将radius属性初始化为1
+setRadius(double radius):void
+getRadius():double
+findArea():double 计算圆的面积
Cylinder
-length:double
Cylinder():构造方法,将length属性初始化为1
+setLength(double length):void
+getLength():double
+findVolunme():double 计算圆柱的体积
Circle类
package test6;
public class Circle {
private double radius;
public Circle() {
this.radius=1;
}
public void setRadius(double radius) {
this.radius=radius;
}
public double getRadius() {
return radius;
}
public double findArea() {
return 3.14*radius*radius;
}
}
Cyl