Computer Science 121
Assignment 7
Due: April 2, 2003

For this assignment you are to create a program with a class that defines a polygon, such as a pentagon or hexagon.  The polygon should have 5, 6, 7, or 8 sides.  The class should have a method that displays the polygon.  See the Triangles applet for an example of this.

A polygon is defined by the positions of its vertices.  These are stored in two arrays, one for all the x coordinates and the other for the y coordinates.  The arrays must be the same size, and the size is a parameter to the fillPolygon method along with the two arrays.

Use a for or while loop in the paint method of the applet in order to create several different polygons.  Because we are using an initializer list, the arrays of coordinates must be declared and initialized within the for loop of the paint method.  Again see the Triangles example.

Also answer these questions.

1. How many points did you include in your polygon, and how did you decide on the shape?

2. How did you choose the colors that you used for your applet?

3. How did you design the applet?  Is it just an abstract design or is it meant to look like something?