10 date 2007.08.16.19.10.01; author vcss232; state Exp;
35 * A simple test program to test the exceptions thrown by the Circle class.
37 * @@author Jim Vallino
41 public class TestCircle {
44 * Create Circle objects trying to force exceptions to occur.
50 // Test the negative radius exception.
53 theCircle = new Circle( 1.0, 1.0, -2.0 );
55 "Did not get expected exception after negative radius." );
56 } catch( ShapeException e ) {
57 System.out.println( "Exception after negative radius." );
58 System.out.print( "The message text was: " );
59 System.out.println( e.getMessage() );
62 // Test the negative stretch factor exception
65 theCircle = new Circle( 1.0, 1.0, 4.0 );
67 theCircle.stretchBy( -3 );
68 System.out.println( "Did not get expected exception after "
69 + "negative stretch." );
70 } catch( ShapeException e ) {
71 System.out.println( "Exception after negative stretch factor." );
72 System.out.print( "The message text was: " );
73 System.out.println( e.getMessage() );
76 // Perform operations that should not generate exceptions.
79 theCircle = new Circle( 1.0, 1.0, 4.0 );
81 System.out.println( "The circle area is " + theCircle.area() );
82 theCircle.stretchBy( 3 );
83 System.out.println( "After stretching the area is "
85 } catch( ShapeException e ) {
86 System.out.println( "Unexpected exception." );
87 System.out.print( "The message text was: " );
88 System.out.println( e.getMessage() );
94 * Instantiate a TestCircle object to check the performance of the
95 * new ShapeException class.
97 * @@param args command line arguments (ignored).
99 public static void main( String[] args ) {
101 test = new TestCircle();