cylinder2.java

来自「java课件」· Java 代码 · 共 34 行

JAVA
34
字号
public class Cylinder2 extends Circle {  private double length;    //无参构造方法  public Cylinder2(){    super();  //调用父类无参构造方法, 此句可以省略    length = 1.0;  }    //使用2个参数构造Cylinder  public Cylinder2(double radius, double length){    super(radius);    this.length = length;  }  /** Return length */  public double getLength() {    return length;  }    /** Set length */  public void setLength(double length) {    this.length = length;  }    //覆盖父类的findArea()方法  public double findArea(){    return 2 * super.findArea() +            2 * getRadius() * Math.PI * length;  }  /** Return the volume of this cylinder */  public double findVolume() {    return super.findArea() * length;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?