public class yuan {
public static void main(string[] args) {
circle test=new circle(5);
system.out.println("周长为"+test.makec());
system.out.println("面积为"+test.area(test.ban));
cylinder test2=new cylinder(10, 5);
system.out.println("圆柱底面积为"+test2.dimianji());
system.out.println("圆柱表面积为"+test2.getbmj());
system.out.println("圆柱体积为"+test2.gettj());
}
}
interface circleshape{
public double pi=3.1415926535;
default double area(double ban) {
return pi*math.pow(ban, 2);
}
}
class circle implements circleshape{
public double ban;
public circle(double ban) {this.ban=ban;
}
public double makec() {
return 2*pi*ban;
}
}
class cylinder extends circle implements circleshape{//先继承后实现,记住顺序
double yzdmbj;
double yzh;
public cylinder(double yzh,double ban){super(ban);
this.yzh=yzh;
}
public double getbmj(){
return 2*area(ban)+2*pi*ban*yzh;
}
public double dimianji() {
return area(ban);
}
public double gettj() {
return area(ban)*yzh;
}
}