圆的面积,周长,圆柱体的体积

public class Point {
private float x;
private float y;
private float getX() {
return x;
}
private void setX(float x) {;
this.x = x;
}
private float getY() {
return y;
}
private void setY(float y) {;
this.y = y;
}
}
//圆形
public class Circle {
private Point center;
private float radius;
private final double PI = Math.PI;
private Point getCenter() {
return center;
}
private void setCenter(Point center) {;
this.center = center;
}
private float getRadius() {
return radius;
}
private void setRadius(float radius) {;
this.radius = radius;
}
//计算面积
public float getArea() {
return (float)radius*PI;
}
}
//圆柱体
public class Cylinder {
private Circle circle;
private float height;
private Circle getCircle() {
return circle;
}
private void setCircle(Circle circle) {;
this.circle = circle;
}
private float getHeight() {
return height;
}
private void setHeight(float height) {;
this.height = height;
}
//得到体积
public float getVolume() {
return height*circle.getArea();
}
}

猜你喜欢

转载自www.cnblogs.com/zhm1234/p/8933931.html
今日推荐