For these problems, you need to use arrays not ArrayLists
9A
Write the class OliverPicsArray. This class encapsulates an array (not an ArrayList) of Pictures and provides methods to process the array.
The constructor takes an array of Pictures as a parameter and uses it to initialize the instance variable.
Provide the methods
public void exchange(int index1, int index2) Exchanges the pictures at the given indexes. Make sure the indices are valid. If not, do not try to exchangepublic Picture tallest() Gets the tallest picture. If the array is empty, return an empty picture - new Picture()public void tallestLast() Remove the tallest picture from the array and add it to the end of the array. (see page 320) public void draw() Draws the pictures vertically with a 5 pixel gap between pictures. The upper left hand corner of the first picture is at 0,0. Consider using Picture's getMaxY() method.Define and use a local constant for GAP. "Local" means you will define it in the draw method.
Provide Javadoc
For the draft, implement the the constructor and the draw() method. Include Javadoc
The pictures are in this zip, oliver_pics.zip. Download, unzip, and put the pictures in the Bluej project folder. Or use the pictures you downloaded for hw8
This homework is much the same as hw8a except it uses an array rather than an ArrayList. Which do you find easier -especially for the tallestLast method.
9B
Write the class Keywords which has an array of Strings as an instance variable and methods to act on the array. Call the instance variable words
Provide a constructor that takes an array of Strings as a parameter and assigns it to the instance variable
Provide methods:
averageLength() gets the average length of the phrases in the array or 0 if the array is emptyshortest() gets the shortest phrase or null if the array is empty. If two phrases have the same shortest length, return the firstallCaps changes every word in the array to uppercasetoString() returns a string representation of this Keywords object (already done for you)Here is the toString method. Copy it into your project.
@Override
public String toString()
{
return Arrays.toString(words);
}
Provide Javadoc
For the draft, provide the instance variable, the constructor and the averageLength() method. Implement the other methods as stubs (including Javadoc). Remember that the Javadoc for a stub should reflect what the method will do in the final version not what it does in the draft.
9C
Util2D creates an 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 write the whole class
Provide the constructor
Provide these methods
getSmallest() Gets the smallest integer in the arraynumberOfEvenInColumn(int column) Gets the number of even integers in the specified column. Remember both positive and negative numbers can be even.last() Gets the element in the last column of the last rowcontains(int target) Returns true if the target is in the array, otherwise falseProvide 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