$24
Problem 1
Create a hierarchy of Java classes as follows:
1. Polygon _is_a_ Shape
2. Circle _is_a_ Shape
Class Shape
Class Shape is an _abstract_ superclass of the hierarchy and inherits Java class Object. An implementation of the Class defines a point _(x,y)_ and the color of the shape. The class includes appropriate class constructors and methods that perform the following operations:
1. _getX, getY, getColor_ - returns the point _(x,y)_ and color for the Shape object;
2. _setX, setY, setColor_ - sets the point _(x,y)_ and color for the Shape object;
3. _moveTo_ - moves point _(x, y)_ to point _(x + ∆x, y + ∆y)_;
4. _toString_ - returns the object’s description as a String. This method must be overridden in each subclass in the hierarchy.
5. _Draw_ - This method must be overridden in each subclass in the hierarchy. For the Shape object, it paints the drawing panel in color.
Class Polygon
Class Polygon inherits class Shape. The Polygon object is a regular polygon defined by the integer parameter _N_ - the number of the polygon’s equal side lengths and equal interior angles. The Polygon object may be filled with a color. The class includes appropriate class constructors and methods that perform the following operations:
1. _getArea_ - returns the area of the Polygon object;
2. _getPerimeter_ - returns the perimeter of the Polygon object;
3. _getAngle_ - return the interior angle (indegrees) of the Polygon object;
4. _getSide_ - returns the side length of the Polygon object;
5. _toString_ - returns a string representation of the Polygon object: side length, interior angle, perimeter, and area;
6. _draw_ - draws a Polygon object whose center point _(x, y)_ is defined in class Shape and inscribed in a circle of radius radius.
Class Circle
Class Circle inherits class Shape. The Circle object is defined by its radius, _radius_, and center _(x, y)_, and may be filled with a color. The class includes appropriate class constructors and methods that perform the following operations:
1. _getArea_ - returns the area of the Circle object;
2. _getPerimeter_ - returns the perimeter of the Circle object;
3. _getRadius_ - returns the radius of the Circle object;
4. _toString_ - returns a string representation of the Circle object: radius, perimeter, and area;
5. _draw_ - draw a Circle object of radius radius. The center point _(x, y)_ of the circle is defined in class Shape.
Problem 2
Test the Polygon class to draw Polygon objects for N = 3 (Triangle), 5(Pentagon), 8(Octagon). Display the string representation of the objects drawn on the drawing panel.
Problem 3
3. Test the classes defined to draw the geometric configuration in Exercise _Concentric pentagons and circles_.