Question
Java: Finish the class Rectangles. It contains methods that manipulate an ArrayList of Rectangles Rectangles has an instance variable ArrayList Call the instance variable list
Java:
Finish the class Rectangles. It contains methods that manipulate an ArrayList of Rectangles
Rectangles has an instance variable ArrayList
It has methods
public void add(Rectangle r) adds this Rectangle to the ArrayList of Rectangles
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. If the Rectangles object is empty, return null
public String toString() gets a string representation of the ArrayList - 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
Provide Javadoc
Note that if you do not implement the methods in order, you may not get the expected results until all the methods are implemented
Please check the answer here: http://www.codecheck.it/files/1707300529eo20qs6aeuc8rtj06pzakdv00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started