按要求编写Java应用程序: (1)定义圆形类Circle,具有属性半径,有求面积的方法getArea,在构造方法中用参数对属性进行初始化。圆周率取值为3.14。 (2)定义圆锥类Cone,属性有Circ
package c; public class Circle { double radius; public Circle(double radius) { this.radius=radius; } public double getArea(){ return 3.14*radius*radius; } } package c; public class Cone { Circle bottom; double height; public Cone(Circle bottom, double height) { super(); this.bottom = bottom; this.height = height; } double getCubage(){ return 1.0/3*bottom.getArea()*height; } } package c; public class TestCone { public static void main(String[] args) { Circle myCircle=new Circle(3); Cone myCone=new Cone(myCircle,2); System.out.println("半径:"+myCircle.radius+" 圆锥体积"+ myCone.getCubage()); } }