📄 cylinder.java
字号:
// Cylinder.java: 圆柱体扩展类Circle
class Cylinder extends Circle
{
private double length;
// Default constructor
public Cylinder()
{
super();
length = 1.0;
}
// Construct a cylinder with specified radius, and length
public Cylinder(double r, double l)
{
super(r);
length=l;
}
// Getter method for length
public double getLength()
{
return length;
}
// Setter method for length
public void setLength(double length)
{
this.length = length;
}
// Find cylinder surface area
public double findArea()
{
return 2*super.findArea()+(2*getRadius()*Math.PI)*length;
}
// Find cylinder volume
public double findVolume()
{
return super.findArea()*length;
}
// Override the toString() method defined in the Object class
public String toString()
{
return "[Cylinder] radius = " + radius + " and length "
+ length;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -