Area of a circle, perimeter, volume of a cylinder

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();
}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324820295&siteId=291194637