| JRoboTest.java |
// JRobo Example 3
// Demonstrates rect method added here.
// Author: David 4/9/99
import java.awt.*;
import java.applet.*;
public class JRoboTest extends Applet
{
public void paint( Graphics g )
{
JRobo aRobo = new JRobo( g );
aRobo.f( 100 );
aRobo.r( 45 );
aRobo.f( 50 );
rect( aRobo, 100,50 );
JRobo robby = new JRobo( g );
robby.l( 45 );
robby.f( 150 );
rect( robby, 25, 25 );
}
// Get the given JRobo to draw rectangle with given height and width
// Pre: Facing north, pen down, bottom left corner.
// Post: as pre-cond., with rectangle drawn.
public void rect( JRobo x, int height, int width )
{
x.f( height );
x.r( 90 );
x.f( width );
x.r( 90 );
x.f( height );
x.r( 90 );
x.f( width );
x.r( 90 );
}
} // end JRoboTest class