实验四 类的继承
实验目的 掌握类的继承方法;变量的继承和覆盖,方法的继承、重载和覆盖实现; 实验内容package cylinder; import circle.Circle; public class Cylinder extends Circle { public double heiht; public Cylinder() {} public Cylinder(double r,double h) { this.heiht=h; super.setRadius(r); } public double getHeiht() { return heiht; } public void setHeiht(double heiht) { this.heiht = heiht; } public double getVol() { return heiht*Math.pow(super.getRadius(),2)*Math.PI; } public void dispVol() { System.out.println("圆柱体的体积是:"+String.format("%.2f", getVol())); } }
