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