-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeartClass.java
More file actions
67 lines (52 loc) · 1.41 KB
/
HeartClass.java
File metadata and controls
67 lines (52 loc) · 1.41 KB
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
// The DiamondClass Class
// Second in a series of demonstration programs for introducing Java
import hsa.Console;
import java.awt.*;
class HeartClass extends SuitClass
{
HeartClass ()
{
}
HeartClass (int h)
{
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;
c.setColor (iColor);
c.fillArc (iPointsX [3], iPointsY [3], width / 2, height / 2, 0, 180);
c.fillArc (iPointsX [4], iPointsY [4], width / 2, height / 2, 0, 180);
c.fillPolygon (iPointsX, iPointsY, 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;
g.setColor (iColor);
g.fillArc (iPointsX [3], iPointsY [3], width / 2, height / 2, 0, 180);
g.fillArc (iPointsX [4], iPointsY [4], width / 2, height / 2, 0, 180);
g.fillPolygon (iPointsX, iPointsY, 3);
}
}