// Inheritance Project // shapehierarchy Module // Source code file: Test3.java // Implements this inheritance hierarchy: // Rectangle --> Shape <-- Circle // Instance variables are set with the constructor. import java.util.ArrayList; public class Test3 { public static void main(String[] args) { // Define Shape objects. Shape s = new Shape(255, 0, 0); Rectangle r = new Rectangle(0, 255, 0, 2.5, 3.5); Circle c = new Circle(0, 0, 255, 3.0); // Add Shape objects to ArrayList collection. ArrayList col = new ArrayList( ); col.add(s); col.add(r); col.add(c); // Print objects using their toString methods for(Shape obj : col) { System.out.println(obj); } System.out.println( ); // Print colors of objects for(Shape obj : col) { System.out.println(obj.getColor( )); } // Print areas of objects System.out.println( ); for(Shape obj : col) { System.out.printf("%8.4f\n", obj.getArea( )); } System.out.println( ); } }