9A
In the PointsGalore class, finish the drawRectangle method.
PointsGalore has a constructor that takes an ArrayList of Points as a parameter. The constructor is provided
The drawRectangle method fills small circles at the points (provided) and then draws the smallest Rectangle that contains the points (you will do this)
Note: Points that fall on the rectangle boundary will not look like they are entirely inside because the points are drawn as ellipses with width and height while a point does not actually have dimensions.
The Point object is defined in java.awt.Point. The only thing you need to know about the class is that you have to import it and that it has getX and getY methods which return doubles.
You will need to import the Udacity graphics package into
Best programming practices dictate that you should use several helper methods rather than have one long method. That means you should write helper methods to get the maximum and minimum x coordinate and the maximum and minimum y coordinate
For the draft, draw a rectangle whose upper left-hand corner is at the coordinates of the Point at index 0 and which has a width of 50 and a height of 30.
9B
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 parameterpublic 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 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
For the draft, implement the constructor and helper method area()
9C
Util2DInteger manages a 2d array of ints. It has a constructor that takes a 2d array as a parameter and assigns it to the instance variable.
You will write the whole class.
Provide the constructor and instance variable.
Provide these methods
getSmallest() Gets the smallest integer in the arraypublic int product() gets the product of the elements in the array. It would probably be easiest to initialize product to 1. [Note: product means multiply]last() Gets the element in the last column of the last row contains(int target) Returns true if the target is in the array, otherwise false Provide Javadoc
For the draft, provide the constructor and the getSmallest method. Implement the other methods as stubs. Remember that a stub for a boolean method returns false. Provide Javadoc. Remember the Javadoc should say what the method will do in the final not what it does in the draft.