You will need to recompile both classes whenever you make a change.
The final output ought to look something like this:
Here's the code for the RecDemo class. Feel free to just copy and
paste it into your editor.
//RecDemo
//used to demonstrate Rectangle class
//By Andy Harris, 5/11/97
import java.awt.*;
import java.applet.*;
import Rectangle;
public class RecDemo extends Applet{
Rectangle myRec;
public void init(){
//test '2 double' constructor and getValues
myRec = new Rectangle (3d, 5d);
add(new Label(myRec.getValues()));
//test 'no parameter' constructor
myRec = new Rectangle ();
add(new Label(myRec.getValues()));
//test 'one int' constructor
myRec = new Rectangle (Rectangle.SMALL);
add(new Label(myRec.getValues()));
myRec = new Rectangle (Rectangle.MEDIUM);
add(new Label(myRec.getValues()));
myRec = new Rectangle (Rectangle.LARGE);
add(new Label(myRec.getValues()));
//test static methods
String outString = new String();
outString = "Perim of 5,6: ";
outString += String.valueOf(Rectangle.calcPerimeter(5d,6d));
add(new Label(outString));
outString = "Area of 5,6: ";
outString += String.valueOf(Rectangle.calcArea(5d,6d));
add(new Label(outString));
} // end init
} // end class def
Here's a link to the same file if that is
easier for you.
© Andy Harris
Indiana University / Purdue University, Indianapolis
email:
aharris@cs.iupui.edu
homepage:
http://www.cs.iupui.edu/~aharris