generated from mengjiaocyr/irregular-polygon-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathIrregularPolygon.java
More file actions
42 lines (34 loc) · 1.15 KB
/
IrregularPolygon.java
File metadata and controls
42 lines (34 loc) · 1.15 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
import java.awt.geom.*; // for Point2D.Double
import java.util.ArrayList; // for ArrayList
import java.util.concurrent.TimeUnit;
import gpdraw.*; // for DrawingTool
public class IrregularPolygon {
private ArrayList<Point2D.Double> myPolygon = new ArrayList<Point2D.Double>();
// constructor
public IrregularPolygon() {}
// public methods
public void add(Point2D.Double aPoint)
{
// TODO: Add a point to the IrregularPolygon.
}
public double perimeter() {
// TODO: Calculate the perimeter.
return 3.14;
}
public double area() {
// TODO: Calculate the area.
return 0.0;
}
public void draw()
{
// Wrap the DrawingTool in a try/catch to allow development without need for graphics.
try {
// TODO: Draw the polygon.
// Documents: https://pavao.org/compsci/gpdraw/html/gpdraw/DrawingTool.html
DrawingTool pen = new DrawingTool(new SketchPad(500, 500));
pen.move(50, 50);
} catch (java.awt.HeadlessException e) {
System.out.println("Exception: No graphics support available.");
}
}
}