class Polygon (slide 2 of 3)
if (vertices.size() < 3) return 0.0;
Enumeration enum = vertices.elements();
Point firstVertex = (Point) enum.nextElement();
Point lastVertex = firstVertex;
while(enum.hasMoreElements()) {
Point thisVertex = (Point) enum.nextElement();
total += areaUnderSegment(lastVertex, thisVertex);
total += areaUnderSegment(lastVertex, firstVertex);
private double areaUnderSegment(Point p1, Point p2) {
return (p1.x - p2.x) * (p1.y + p2.y) / 2;