We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent da0053b commit aa248dcCopy full SHA for aa248dc
1 file changed
ch16/ColorPolygon.java
@@ -0,0 +1,30 @@
1
+import java.awt.Color;
2
+import java.awt.Graphics;
3
+import java.awt.Polygon;
4
+
5
+/**
6
+ * Specialization of Polygon that has a color and the ability to draw itself.
7
+ */
8
+public class ColorPolygon extends Polygon {
9
10
+ public Color color;
11
12
+ /**
13
+ * Creates an empty polygon.
14
15
+ public ColorPolygon() {
16
+ super();
17
+ color = Color.GRAY;
18
+ }
19
20
21
+ * Draws the polygon on the screen.
22
+ *
23
+ * @param g graphics context
24
25
+ public void draw(Graphics g) {
26
+ g.setColor(color);
27
+ g.fillPolygon(this);
28
29
30
+}
0 commit comments