/**
* * @param x * @param y * * Populate the instance variable array,
points, using the arrays x and y. * Each corresponding pair in the
two arrays; x, y; represents one point. * * use the first n
items where n is the smaller of x.length and y.length * * in case
of either array being null, initialize the array to an empty one.
*/
public Polygon(int[] x, int[] y) {
if (x == null) {
x = new int[0]; //Initialization to empty array
}
if (y == null) {
y = new int[0]; //Initialization to empty array
}
int n; if (x.length < y.length) { n = x.length; }
else { n = y.length; } Point[] arr = new Point[n]; this.points =
arr; for (int i = 0; i < x.length; i++) { for (int a = 0; a <
y.length; a++) {
for (int b = 0; b < arr.length; b++) { arr = new
Point(x,y[a]); } } } }
/** * * @param x * @param y * * Populate the instance variable array, points, using the arrays x and y. * Each correspon
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
/** * * @param x * @param y * * Populate the instance variable array, points, using the arrays x and y. * Each correspon
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!