Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa248dc

Browse filesBrowse files
committed
added ColorPolygon
1 parent da0053b commit aa248dc
Copy full SHA for aa248dc

File tree

Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Collapse file

‎ch16/ColorPolygon.java‎

Copy file name to clipboard
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.