class Circle {
private double radius;
public Circle() {
this.radius = 0;
}
public Circle(double radius) {
this.radius = radius;
}
public double getArea() {
return Math.PI * Math.pow(radius, 2);
}
public double getPerimenter() {
return Math.PI * 2 * radius;
}
public void show() {
System.out.println("圆的半径" + radius);
System.out.println("圆的周长" + getPerimenter());
System.out.println("圆的面积" + getArea());
}
}
class Cylinder extends Circle {
private double hight;
public Cylinder(double r, double h) {
super(r);
this.hight = h;
}
public double getVolume() {
return getArea() * hight;
}
public void showVolume() {
System.out.println("圆柱的体积" + getVolume());
}
}
public class H1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Cylinder b = new Cylinder(1, 1);
b.show();
b.showVolume();
}
}
private double radius;
public Circle() {
this.radius = 0;
}
public Circle(double radius) {
this.radius = radius;
}
public double getArea() {
return Math.PI * Math.pow(radius, 2);
}
public double getPerimenter() {
return Math.PI * 2 * radius;
}
public void show() {
System.out.println("圆的半径" + radius);
System.out.println("圆的周长" + getPerimenter());
System.out.println("圆的面积" + getArea());
}
}
class Cylinder extends Circle {
private double hight;
public Cylinder(double r, double h) {
super(r);
this.hight = h;
}
public double getVolume() {
return getArea() * hight;
}
public void showVolume() {
System.out.println("圆柱的体积" + getVolume());
}
}
public class H1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Cylinder b = new Cylinder(1, 1);
b.show();
b.showVolume();
}
}









