1.掌握父类与子类,理解对象的上转型对象,理解抽象类和抽象方法,掌握面向抽象的编程思想和开闭原则
2.创建底面为正方形的柱体类,计算柱体类的体积。
3当底面为圆形或三角形时,分析程序的拓展性和复用性。
package zilei;
public abstract class Geometry {
abstract double getArea();
}
package zilei;
public class Pillar {
public Pillar() {
super();
// TODO Auto-generated constructor stub
}
public Pillar(Geometry bottom, double height) {
super();
this.bottom = bottom;
this.height = height;
}
Geometry bottom;
double height;
double getVolume() {
return bottom.getArea()*height;
}
}
package zilei;
public class Circle extends Geometry {
public Circle() {
super();
/