11import java .awt .Color ;
2- import java .awt .Graphics ;
3- import java .awt .Polygon ;
42
53/**
64 * A polygon that is equiangular (all angles are equal in measure) and
75 * equilateral (all sides have the same length). It also has a color.
86 */
9- public class RegularPolygon extends Polygon implements Actor {
7+ public class RegularPolygon extends ColorPolygon {
108
119 public static final String [] NAMES = {null , null , null ,
1210 "Triangle" , "Square" , "Pentagon" , "Hexagon" ,
1311 "Heptagon" , "Octagon" , "Nonagon" , "Decagon" };
1412
15- protected Color color ;
16-
1713 /**
1814 * Constructs a regular polygon, given the number of sides.
1915 *
@@ -43,7 +39,7 @@ public RegularPolygon(int nsides, int radius) {
4339 */
4440 public RegularPolygon (int nsides , int radius , Color color ) {
4541
46- // validate and store arguments
42+ // validate the arguments
4743 if (nsides < 3 ) {
4844 throw new IllegalArgumentException ("invalid nsides" );
4945 }
@@ -60,7 +56,7 @@ public RegularPolygon(int nsides, int radius, Color color) {
6056 this .ypoints = new int [nsides ];
6157 this .color = color ;
6258
63- // the angle (in radians) at each vertex
59+ // the angle (in radians) for each vertex
6460 double angle = 2.0 * Math .PI / nsides ;
6561
6662 // rotation that makes the polygon right-side up
@@ -75,17 +71,6 @@ public RegularPolygon(int nsides, int radius, Color color) {
7571 }
7672 }
7773
78- @ Override
79- public void draw (Graphics g ) {
80- g .setColor (color );
81- g .fillPolygon (this );
82- }
83-
84- @ Override
85- public void step () {
86- // do nothing
87- }
88-
8974 @ Override
9075 public String toString () {
9176 StringBuilder str = new StringBuilder ();
0 commit comments