Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Call the instance variable list. It has a constructor that takes no parameters but initializes the instance variable to an empty 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions