实验八

public class Du {
public static void main(String[] args) {
}
}
class Rectangle{
protected double length;
protected double width;
public Rectangle(double length, double width){
this.length = length;
this.width = width;
}
}
interface Volume{
public double volume();
}
class YuanZhu extends Rectangle implements Volume{//圆柱体类
private double r;
public YuanZhu(double length, double width) {
super(length, width);
this.r = length / 2 / Math.PI;
}
public double volume() {
return Math.PI * Math.pow(r, 2) * width;
}
}
class YuanZhui extends Rectangle implements Volume{//圆锥体类
private double r;
public YuanZhui(double length, double width) {
super(length, width);
this.r = length /2 / Math.PI;
}
public double volume() {
return Math.PI * Math.pow(r, 2) * width / 3;
}

心得    自己还是没有跟上进度,很难完成。

posted @ 2019-05-19 23:46  zengtaicuomao  阅读(162)  评论(1编辑  收藏  举报