-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClubClass.java
89 lines (70 loc) · 2.06 KB
/
ClubClass.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// The DiamondClass Class
// Second in a series of demonstration programs for introducing Java
import hsa.Console;
import java.awt.*;
class ClubClass extends SuitClass
{
ClubClass ()
{
}
ClubClass (int h)
{
super.setHeight (h);
}
public void draw (Console c)
{
int iPointsX[] = new int [5];
int iPointsY[] = new int [5];
iPointsX [0] = cx - width / 2;
iPointsY [0] = cy;
iPointsX [1] = cx + width / 2;
iPointsY [1] = cy;
iPointsX [2] = cx;
iPointsY [2] = cy - height / 2;
iPointsX [3] = cx - width / 2;
iPointsY [3] = cy - height / 4;
iPointsX [4] = cx;
iPointsY [4] = cy - height / 4;
int triPointsX[] = new int [3];
int triPointsY[] = new int [3];
triPointsX [0] = cx;
triPointsY [0] = cy - height / 4;
triPointsX [1] = cx - width / 8;
triPointsY [1] = cy + height / 2;
triPointsX [2] = cx + width / 8;
triPointsY [2] = cy + height / 2;
c.setColor (iColor);
c.fillOval (iPointsX [3], iPointsY [3], width / 2, height / 2);
c.fillOval (iPointsX [4], iPointsY [4], width / 2, height / 2);
c.fillOval (cx - width / 4, cy - 4 * (height / 7), width / 2, height / 2);
c.fillPolygon (triPointsX, triPointsY, 3);
}
public void draw (Graphics g)
{
int iPointsX[] = new int [5];
int iPointsY[] = new int [5];
iPointsX [0] = cx - width / 2;
iPointsY [0] = cy;
iPointsX [1] = cx + width / 2;
iPointsY [1] = cy;
iPointsX [2] = cx;
iPointsY [2] = cy - height / 2;
iPointsX [3] = cx - width / 2;
iPointsY [3] = cy - height / 4;
iPointsX [4] = cx;
iPointsY [4] = cy - height / 4;
int triPointsX[] = new int [3];
int triPointsY[] = new int [3];
triPointsX [0] = cx;
triPointsY [0] = cy - height / 4;
triPointsX [1] = cx - width / 8;
triPointsY [1] = cy + height / 2;
triPointsX [2] = cx + width / 8;
triPointsY [2] = cy + height / 2;
g.setColor (iColor);
g.fillOval (iPointsX [3], iPointsY [3], width / 2, height / 2);
g.fillOval (iPointsX [4], iPointsY [4], width / 2, height / 2);
g.fillOval (cx - width / 4, cy - 4 * (height / 7), width / 2, height / 2);
g.fillPolygon (triPointsX, triPointsY, 3);
}
}