9A
Write a class called ArrayListFlowers. In the main method, do the following in the main method
Note: it is possible to pass Codecheck without using any of the ArrayList methods, but you will get no credit for that.
For the draft,
9B
Complete the class StringArrayList
. It contains methods that manipulate an ArrayList of Strings. It has an instance variable of an ArrayList of Strings. Call it list. Its constructor takes an ArrayList of Strings as a parameter. In addition to the Constructor, you need to implement the following methods
The methods
public void swap(int index1, int index2)
- swaps the element at index1 with the element at index2.If either index is out of bounds, return without changing anything. Write your own swap method. Do not use one from the Java librarypublic void replaceVowelsWith(String text)
Replaces each vowel in every ArrayList element with the replacement value text.public boolean equals(StringArrayList other)
- Determines if the other StringArrayList
contains all the same elements in the same order as this StringArrayList
I have provided a toString
method to aid testing. (This is why the instance variable must be called list.)
Provide Javadoc
For the draft, provide the instance variable, the constructor and the swap
method. Include Javadoc
9C
Complete the RectangleManager
class. A RectangleManager
manipulates an ArrayList of Rectangles. It already has the instance variable declared (an ArrayList of Rectangles) and a toString method.
public RectangleManager()
a no-argument constructor. It should initialize the instance variable (be careful not to redefine list instance variable)public void add(Rectangle r)
adds a Rectangle to this RectangleManager
public double totalArea()
gets the sum of areas of all the Rectangles in this RectangleManager
or 0 if the RectangleManager has no Rectanglespublic Rectangle largest(
) gets the Rectangle with the largest area. Returns null if the RectangleManager has no Rectangles. Returns the first occurrence if two rectangles have the largest area.Provide Javadoc
For the draft, provide the constructor and code the add()
method. You will also need to import the ArrayList class from the Java library as well as the graphics classes. Provide Javadoc