Geometry.java
public abstract class Geometry {
public abstract double getArea();
}
TotalArea.java
public class TotalArea {
Geometry[] tuxing;
double totalArea=0;
public void setTuxing(Geometry[] t) {
tuxing=t;
}
public double computerTotalArea() {
for(int i=0;i
Rect.java
public class Rect extends Geometry {
double a,b;
Rect(double a,double b) {
this.a = a;
this.b = b;
}
public double getArea(){
return a*b;
}
}
Circle.java
public class Circle extends Geometry {
double r;
Circle(double r) {
this.r = r;
}
public double getArea(){
return 3.14*r*r;
}
}
MainClass.java
public class MainClass{
public static void main(String args[]) {
Geometry [] tuxing=new Geometry[29];
for(int i=0;i
运行结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)