$24
Problem
Consider the class hierarchy in Exercise 2.
1. Amend the hierarchy of Java classes in Exercise 2 as follows:
Polygon is_a Shape;
Rectangle is_a Shape;
Oval is_a Shape;
Circle is_a Oval;
2. Interface ShapeIntergace, interface PositionInterface, and interface
ShapePositionInterface are specified in connection with the class hierarchy.
3. Interface ShapeInterface includes appropriate abstract, static, and/or default methods that
describe the intrinsic functions and behaviors of the specific object types of the class
hierarchy, incuding:
a. getArea – describes the area of an object in the class hierarchy;
b. getPerimeter – describes the perimeter of an object in the class hieracrchy.
4. Interface PositionInterface includes appropriate abstract, static, and/or default methods that
describe the positional functions and behaviors of the specific object type of the class
hierarchy, including:
a. getPoint – returns the point (x, y);
b. moveTo – moves point (x, y) to point (x + Δx, y + Δy);
c. distanceTo – returns distance from point (x, y) to a point;
5. The abstract class Shape implements interface ShapePositionInterface which extends
interface ShapeInterface and interface PositionInterface. Interface ShapePositionInterface
includes appropriate abstract, static, and/or default methods that describe the functions and
behaviors of the specific object types of the class hierarchy, including:
a. getBoudningBox – returns the bounding rectangle of an object in the class hierarchy;
b. doOverlap – returns true if two objects in the class hierarchy overlap.
6. Build a class Application that processes polymorphically the subclasses in the hierarchy to
draw the geometric object shown: