Question: Finish the class RectanglesArray. It contains methods that manipulate an array (not an ArrayList) Rectangles has an instance variable Rectangle[] Call the instance variable list
Finish the class RectanglesArray. It contains methods that manipulate an array (not an ArrayList)
Rectangles has an instance variable Rectangle[] Call the instance variable list. It has a constructor that takes an array of Rectangles as a parameter and initializes the instance variable with it.
It has methods
public double averageArea() finds the average area of a Rectangles in this array. Use the helper method area described below. Do not calculate the area in this method.
public void swap(int index1, int index2) - swaps the element at index1 with the element at index2. If either index is out of bounds, do not changing anything.
public Rectangle largest() gets the Rectangle with the largest area. If more than one Rectangle has the same areas, return the first. Use the helper method area described below. Do not calculate the area in this method.
public double area(Rectangle r) gets the area of the rectangle parameter
public String toString() gets a string representation of the array - provided. (This is why the instance variable must be called list.)
You will need to import the Udacity graphics package(https://s3.amazonaws.com/udacity-hosted-downloads/graphics.zip) in order to use Rectangle
largest and swap are similar to the methods in 8c. Those processed an ArrayList. These work with arrays.
Provide Javadoc.
Please check the answer here: http://www.codecheck.it/files/17073102476smv0eto3hj4ryt74xviq5esw
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
