// Fig. 7.8: Test.java // Applet to test class Cylinder import java.awt.Graphics; import java.applet.Applet; import java.text.*; import com.deitel.jhtp2.ch07.Cylinder; public class Test extends Applet { private Cylinder c; public void init() { c = new Cylinder( 5.7, 2.5, 12, 23 ); } public void paint( Graphics g ) { DecimalFormat precision2 = new DecimalFormat( "#.00" ); g.drawString( "X coordinate is " + c.getX(), 25, 25 ); g.drawString( "Y coordinate is " + c.getY(), 25, 40 ); g.drawString( "Radius is " + c.getRadius(), 25, 55 ); g.drawString( "Height is " + c.getHeight(), 25, 70 ); c.setHeight( 10 ); c.setRadius( 4.25 ); c.setPoint( 2, 2 ); g.drawString( "The new location, radius and height" + " of c are ", 25, 100 ); g.drawString( c.toString(), 40, 115 ); g.drawString( "Area is " + precision2.format( c.area() ), 25, 130 ); g.drawString( "Volume is " + precision2.format( c.volume() ), 25, 145 ); } }