cylinder.java

来自「该包中定义了几个类」· 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;
	}
	public int getHeight()
	{
		return height;
	}
	double volume()
	{
	  	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.getPoint())&&c.getR()==r&&c.getHeight()==height;
	}
	public String toString()
	{
		return super.toString()+",the height is " +height;
	}
}

⌨️ 快捷键说明

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