public class ShapeBasics implements ShapeInterface
1: //ShapeBasics.java
2:
3: /**
4: * Class for drawing simple shapes on the screen using keyboard
5: * characters. This class will draw an asterisk on the screen as a
6: * test. It is not intended to create a "real" shape, but rather
7: * to be used as a base class for other classes of shapes.
8: */
9: public class ShapeBasics implements ShapeInterface
10: {
11: private int offset;
12:
13: public ShapeBasics()
14: {
15: offset = 0;
16: }
17:
18: public ShapeBasics
19: (
20: int theOffset
21: )
22: {
23: offset = theOffset;
24: }
25:
26: public void setOffset
27: (
28: int newOffset
29: )
30: {
31: offset = newOffset;
32: }
33:
34: public int getOffset()
35: {
36: return offset;
37: }
38:
39: /**
40: * Draws the shape at lineNumber lines down
41: * from the current line.
42: */
43: public void drawAt
44: (
45: int lineNumber
46: )
47: {
48: for (int count = 0; count < lineNumber; count++)
49: System.out.println();
50: drawHere();
51: }
52:
53: /**
54: * Draws the shape at the current line.
55: */
56: public void drawHere()
57: {
58: for (int count = 0; count < offset; count++)
59: System.out.print(' ');
60: System.out.println('*');
61: }
62: }