Create a directory in your repository named a9 and include all of the files for this assignment in the a9 directory.
- Write an class named Point.
- The class should have two private fields that hold integers.
- The class should have a constructor that sets both fields with the values passed into it.
- The class should override toString so that it returns a String with the value “(x,y)” where x and y are the values of the fields.
- The class should override equals and hashCode using both fields as the significant fields.
- Note that order matters: (0,1) is not the same as (1,0).
- Write a class named IllFormedPolygonException.
- Write a class named Polygon.
- The class should contain a field that contains an array of Point objects. To mentally view a Polygon object as a 2D shape we can imagine there are line segments drawn between adjacent Points in the array and a line segment drawn between the first and last Point in the array.
- The class should have a constructor that requires at least three Point objects.
- The class should add to the array the points that are passed into the constructor in the order in which they are passed to the constructor.
- The class should override toString so that it prints each of the points in the array in the order in which they were added.
- The class should override equals and hashCode and consider two Polygons equal if when viewed as 2D shapes (see 3.1) they contain the same line segments.
- The class should implement the Iterable interface and provide an Iterator that iterates over the array of Points.
- The class should implement the Comparable interface. We’ll define comparably larger and comparably equivalent as follows: for any two Polygon objects A and B, A is comparably larger than B if A has more line segments than B. They are comparably equivalent if they contain the same number of line segments.
- Write a driver that thoroughly tests your classes.
For this assignment, I will test your code using a driver that contains 20 test cases. Each test case will be worth 5 points. My test cases will rigorously test your code, so be sure to start early, work diligently, and test your code rigorously.
© 2017 – 2019, Eric. All rights reserved.