文档介绍:{
public static void main(String [] args)
{
Pillar pillar;
Geometry tuXing;
Circle circle = new Circle(new Double(10));
tuXing = circle;
("半径是:" + ().doubleValue()+"的面积是" + ().doubleValue());
pillar = new Pillar(circle,new Double(58));
("底面半径是:%f的圆,高是:%f的圆柱体体积是:%f",().doubleValue()
,().doubleValue(),
().doubleValue());
Lader lader = new Lader(new Double(12),new Double(22),new Double(100));
tuXing = lader;
(tuXing);
("%n上底:%f,下底:%f,高:%f的梯形面积是:%f",().doubleValue()
,().doubleValue()
,().doubleValue()
,().doubleValue());
("%n上底、下底、高分别是:%f%f%f的梯形底,柱高是:%f的柱体体积是:%f",().doubleValue()
,().doubleValue()
,().doubleValue()
,().doubleValue()
,().doubleValue());
}
}
interface Geometry
{
public abstract Double getArea();
}
class Pillar
{
Geometry bottom;
Double height;
Pillar()
{
bottom = null;
height = new Double(0);
}
Pillar(Geometry bottom,Double height)
{
= bottom;
= height;
}
public void setBottom(Geometry bottom)
{
= bottom;
}
public Geometry getBottom()
{
return bottom;
}
publi