public class Figure
1:
2: /**
3: Class for simple character graphics figures to be sent to the
4: screen. This class will draw an asterisk on the screen as a test.
5: It is not intended to be used as a "real" figure in any graphics.
6: It is intended to be used as a base class for other classes
7: of figures that will be used in graphics applications.
8: */
9: public class Figure
10: {
11: private int offset;
12:
13: public Figure( )
14: {
15: offset = 0;
16: }
17:
18: public Figure(int theOffset)
19: {
20: offset = theOffset;
21: }
22:
23: public void setOffset(int newOffset)
24: {
25: offset = newOffset;
26: }
27:
28: public int getOffset( )
29: {
30: return offset;
31: }
32:
33: /**
34: Draws the figure at lineNumber lines down
35: from the current line.
36: */
37: public void drawAt(int lineNumber)
38: {
39: int count;
40: for (count = 0; count < lineNumber; count++)
41: System.out.println( );
42: drawHere( );
43: }
44:
45: /**
46: Draws the figure at the current line.
47: */
48: public void drawHere( )
49: {
50: int count;
51: for (count = 0; count < offset; count++)
52: System.out.print(' ');
53: System.out.println('*');
54: }
55: }