| JRoboTest.java |
1 // JRobo Example 3
2 // Demonstrates rect method added here.
3 // Author: David 4/9/99
4
5 import java.awt.*;
6 import java.applet.*;
7
8 public class JRoboTest extends Applet
9 {
10 public void paint( Graphics g )
11 {
12 JRobo aRobo = new JRobo( g );
13 aRobo.f( 100 );
14 aRobo.r( 45 );
15 aRobo.f( 50 );
16 rect( aRobo, 100,50 );
17
18 JRobo robby = new JRobo( g );
19 robby.l( 45 );
20 robby.f( 150 );
21 rect( robby, 25, 25 );
22 }
23
24 // Get the given JRobo to draw rectangle with given height and width
25 // Pre: Facing north, pen down, bottom left corner.
26 // Post: as pre-cond., with rectangle drawn.
27 public void rect( JRobo x, int height, int width )
28 {
29 x.f( height );
30 x.r( 90 );
31 x.f( width );
32 x.r( 90 );
33 x.f( height );
34 x.r( 90 );
35 x.f( width );
36 x.r( 90 );
37 }
38
39 } // end JRoboTest class
40