/** * * @param x * @param y * * Populate the instance variable array, points, using the arrays x and y. * Each correspon
Posted: Mon May 02, 2022 12:18 pm
/**
* * @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 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]); } } } }