cylinder.java
来自「(1) 编写一个代表圆柱体的Cylinder类」· Java 代码 · 共 37 行
JAVA
37 行
import p3.circle;
import p2.Point;
public class Cylinder extends p3.circle
{
int height;
Cylinder(){}
Cylinder(Point p,int r,int h)
{
super(p,r);
height=h;
}
Cylinder(int x,int y,int r,int h)
{
super(x,y,r);
height=h;
}
int getHeight()
{
return height;
}
double volume()
{ return height*super.area();
//return Math.PI*r*r*height;
}
double surfaceArea()
{
return (2*Math.PI*r*r+2*Math.PI*r*height);
}
public boolean equals(Cylinder c)
{
return center.equals(c.center)&&c.r==r&&c.getHeight()==height;
}
public String toString()
{
return super.toString()+"the heigth is "+height;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?