kashdkjaf
[rmh3093.git] / lab3 / RCS / TestCircle.java,v
blob33cc16eaf213827ba61e7e29991bc1fb793c9adf
1 head    1.1;
2 access;
3 symbols;
4 locks
5         rmh3093:1.1; strict;
6 comment @# @;
9 1.1
10 date    2007.08.16.19.10.01;    author vcss232; state Exp;
11 branches;
12 next    ;
15 desc
19 1.1
20 log
21 @Initial revision
23 text
24 @/* 
25  * TestCircle.java
26  *
27  * Version:
28  *     $Id$
29  * 
30  * Revisions: 
31  *     $Log$
32  */
34 /**
35  * A simple test program to test the exceptions thrown by the Circle class.
36  *
37  * @@author     Jim Vallino
38  *
39  */
41 public class TestCircle {
43     /**
44      * Create Circle objects trying to force exceptions to occur.
45      */
47     public TestCircle() {
48         Circle theCircle;
50         // Test the negative radius exception.
52         try {
53             theCircle = new Circle( 1.0, 1.0, -2.0 );
54             System.out.println(
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() );
60         }
62         // Test the negative stretch factor exception
64         try {
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() );
74         }
76         // Perform operations that should not generate exceptions.
78         try {
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 " 
84                                 + theCircle.area() );
85         } catch( ShapeException e ) {
86             System.out.println( "Unexpected exception." );
87             System.out.print( "The message text was: " );
88             System.out.println( e.getMessage() );
89         }
91     }
92         
93     /**
94      * Instantiate a TestCircle object to check the performance of the
95      * new ShapeException class.
96      *
97      * @@param args command line arguments (ignored).
98      */
99     public static void main( String[] args ) {
100         TestCircle test;
101         test = new TestCircle();
102     }
103     
104 } // TestCircle