Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) Create an abstract class Polygon with the following attributes and behaviors: * private array of Point2D objects (private Point2D[]), which stores the coordinates of
a) Create an abstract class Polygon with the following attributes and behaviors: * private array of Point2D objects (private Point2D[]), which stores the coordinates of the vertices (x,y) of each vertex of the Polygon (it will be assumed that the points are placed in consecutive order so that, if we were to draw lines connecting these points(vertices), no lines would intersect) private String forthe name of the type of Polygon ("Square", for example) * Constructor that receives a Point2D array (of length at least 3) and a String as parameters * Method double perimeter(), which adds the distances between each pair of consecutive points in the array (note, the Point2D class has a method distance(Point2D point2) that will compute the distance from the Point2D calling the method to the point2D passed into the method * Method Point2D[] getPoints(), which returns the array * Abstract method double areal), for which subclasses will be required to implement to calculate the area of the Polygon a) Create an abstract class Polygon with the following attributes and behaviors: * private array of Point2D objects (private Point2D[]), which stores the coordinates of the vertices (x,y) of each vertex of the Polygon (it will be assumed that the points are placed in consecutive order so that, if we were to draw lines connecting these points(vertices), no lines would intersect) private String forthe name of the type of Polygon ("Square", for example) * Constructor that receives a Point2D array (of length at least 3) and a String as parameters * Method double perimeter(), which adds the distances between each pair of consecutive points in the array (note, the Point2D class has a method distance(Point2D point2) that will compute the distance from the Point2D calling the method to the point2D passed into the method * Method Point2D[] getPoints(), which returns the array * Abstract method double areal), for which subclasses will be required to implement to calculate the area of the Polygon
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started