cylinder9.java

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

JAVA
49
字号
public class Cylinder9 extends Circle9 {  private double length;  /** Construct a cylinder with default properties */  public Cylinder9() {    this(1.0, 1.0);  }  /** Construct a cylinder with specified radius, and length */  public Cylinder9(double radius, double length) {    this(radius, "white", false, length);  }  /** Construct a cylinder with specified radius, filled, color, and     length    */  public Cylinder9(double radius,    String color, boolean filled, double length) {    super(radius, color, filled);    this.length = length;  }  /** Return length */  public double getLength() {    return length;  }  /** Set a new length */  public void setLength(double length) {    this.length = length;  }  /** Return the surface area of this cylinder */  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;  }  /** Override the toString method defined in the Object class */  public String toString() {    return "[Cylinder] radius = " + getRadius() + " and length "      + length;  }}

⌨️ 快捷键说明

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