public class Test{
public static void main(String args[]){
Area array[] = new Area[5];
array[0] = new Circle(5,3,2);
array[1] = new Rect(5,3,20,7);
array[2] = new Circle(3,1,1);
array[3] = new Rect(0,0,3,3);
array[4] = new Circle(-5,2,2);
double area = 0; // 面積
area += array[0].getArea();
area += array[1].getArea();
area += array[2].getArea();
area += array[3].getArea();
area += array[4].getArea();
System.out.println("面積の合計="+area);
}
}
|