/* * ============================================================= * TestShape.java: Test Program for Rectangle and Circle Shapes. * ============================================================= */ public class TestShape { public static void main ( String args[] ) { // Create array of shapes Shape s[] = new Shape [3] ; s[0] = new Rectangle( 3.0, 3.0, 2.0, 2.0 ); s[1] = new Circle( 1.0, 2.0, 2.0 ); s[2] = new Rectangle( 2.5, 2.5, 2.0, 2.0 ); // Print details of the array of shapes System.out.println("---------------------"); for (int ii = 1; ii <= s.length; ii = ii + 1) { System.out.println( s[ii-1].toString() ); System.out.println( "Perimeter = " + s[ii-1].perimeter() ); System.out.println( "Area = " + s[ii-1].area() ); System.out.println("---------------------"); } } }