Java provides a method for drawing polygons called drawPolygon. To use it
the student must first create and populate arrays representing the points of the
corners of a polygon:
int x[]=new int[16];
int y[]=new int[16];
x[0]=10; y[0]=10;
// insert all the other points here
x[15]=10; y[15]=20;
Then the student may make the actual call to drawPolygon:
g.drawPolygon(x,y,x.length);
| EXAMPLE: The student will create an applet like the one shown here. This activity provides the student with practice using the drawPolygon method. |
| x |
ASSIGNMENT:
Recreate the applet shown above using the drawPolygon method.