| XJRobo.java |
1 // XJRobo Extension of XJRobo
2 // which adds rect, move & equtri methods.
3 // Author: David 5/9/99
4 // Version: 1.0
5
6 import java.awt.*;
7
8 public class XJRobo extends JRobo
9 {
10 public XJRobo ( Graphics g )
11 {
12 super( g );
13 }
14
15 // rect - Draw rectangle with given height and width
16 // Pre: Facing north, pen down, bottom left corner.
17 // Post: as pre-cond., with rectangle drawn.
18 public void rect( int height, int width )
19 {
20 f( height );
21 r( 90 );
22 f( width );
23 r( 90 );
24 f( height );
25 r( 90 );
26 f( width );
27 r( 90 );
28 }
29
30 // move - reposition JRobo x, +dx, +dy from current location
31 public void move( int dx, int dy )
32 {
33 p();
34 f( dy );
35 r( 90 );
36 f( dx );
37 l( 90 );
38 p();
39 }
40
41 // equtri - draws an equilateral triangle of specified size
42 // Pre: facing north, pen down, bottom left corner
43 // Post: as pre, with triangle drawn.
44 public void equtri( int size)
45 {
46 r( 30 );
47 f( size );
48 r( 120 );
49 f( size );
50 r( 120 );
51 f( size );
52 r( 90 );
53 }
54
55 } // end XJRobo class
56