// Fig. 9.7: CircleTest.java // Testing class Circle. import java.text.DecimalFormat; import javax.swing.JOptionPane; public class CircleTest { public static void main( String[] args ) { Circle circle = new Circle( 37, 43, 2.5 ); // create Circle object // get Circle's initial x-y coordinates and radius String output = "X coordinate is " + circle.getX() + "\nY coordinate is " + circle.getY() + "\nRadius is " + circle.getRadius(); circle.setX( 35 ); // set new x-coordinate circle.setY( 20 ); // set new y-coordinate circle.setRadius( 4.25 ); // set new radius // get String representation of new circle value output += "\n\nThe new location and radius of circle are\n" + circle.toString(); // format floating-point values with 2 digits of precision DecimalFormat twoDigits = new DecimalFormat( "0.00" ); // get Circle's diameter output += "\nDiameter is " + twoDigits.format( circle.getDiameter() ); // get Circle's circumference output += "\nCircumference is " + twoDigits.format( circle.getCircumference() ); // get Circle's area output += "\nArea is " + twoDigits.format( circle.getArea() ); JOptionPane.showMessageDialog( null, output ); // display output System.exit( 0 ); } // end main } // end class CircleTest /************************************************************************** * (C) Copyright 1992-2003 by Deitel & Associates, Inc. and * * Prentice Hall. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/