1: //ShapeBase.java
2:
3: /**
4: * Abstract base class for drawing simple shapes on the screen
5: * using keyboard characters.
6: */
7: public abstract class ShapeBase implements ShapeInterface
8: {
9: private int offset;
10:
11: public ShapeBase()
12: {
13: offset = 0;
14: }
15:
16: public ShapeBase(int theOffset)
17: {
18: offset = theOffset;
19: }
20:
21: /**
22: * Draws the shape at the current line.
23: */
24: public abstract void drawHere();
25:
26: /**
27: * Draws the shape at lineNumber lines down from the
28: * current line. If this is interpreted to mean that
29: * the first character of the figure is to be on the
30: * line lineNumber lines down from the current line,
31: * then we have to skip lineNumber - 1 lines.
32: */
33: public void drawAt
34: (
35: int lineNumber
36: )
37: {
38: for (int count = 0; count < lineNumber - 1; count++)
39: System.out.println();
40: drawHere();
41: }
42:
43: public void setOffset
44: (
45: int newOffset
46: )
47: {
48: offset = newOffset;
49: }
50:
51:
52: public int getOffset()
53: {
54: return offset;
55: }
56: }