Polygon Project
A complete project should include the following features.
1. Polygon.java
a.
Create a utility file named
Polygon.java
that constructs polygons as linked lists
of Points using
the class Point.java that has been provided previously. We will always assume that the last point
connects to the first point without representing this in the class. The number of vertices only counts
the first and last point once however. The polygon ABC has three vertices. Include a default
constructor, a second constructor which given an array
of points creates the obvious polygon. Add a
third constructor which given one polygon and a point D appends D at the end of the polygon. For
example, given the polygon ABC and the point D, the constructor returns the polygon ABCD. Add a
fourth constructor which given two polygons constructs their direct sum. For example
ABC + DEFG = ABCDEFG.
b.
Add a method
print()
which prints out all the points of a polygon. Add a method
numberOfVertices()
which gives the number of vertices in the polygon. Add a method
perimeter()
which adds up the length of all the sides of the polygon. Add an accessor method
getPoint(int n)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 CARR
 Polygons, Method, Regular polygon, Mutator method

Click to edit the document details