Question: Exercise: ArrayList Practice - Create a Netbeans or Ecplise Java project.| (A). the Rectangle class contains two data fields, length and width: type is int.

 Exercise: ArrayList Practice - Create a Netbeans or Ecplise Java project.|

Exercise: ArrayList Practice - Create a Netbeans or Ecplise Java project.| (A). the Rectangle class contains two data fields, length and width: type is int. an initializer constructor, an equals() method as usual, a toString() method: it returns "L: "+length+"\tW: "+width (B). the RectangleList class contains a data field named boxes, type ArrayList such that it stores Rectangle objects a no-arg constructor such that it instantiates boxes a loadBoxes() method which takes and int type parameter for the list size: the method adds size many Rectangle objects to the list such that for each added Rectangle, length is a randomly selected integer number between 1 and 3, width is also a randomly selected integer number between 11 and 13 a reduce() method such that for every given element of the list the method removes all the additional occurrences of the given element. That is, after reduction every element occurs once in the list. the method is void. Use a pair of nested for loops, the equals method of the Rectangle class and local variable(s) as needed, a toString() method such that it returns the toString() value of each list element (C). the Applications class contains the main method. In the method declare and instantiate a RectangleList object named list call loadBoxes() to add 18 Rectangles to the list test loadBoxes: use toString() to print the list to the console call reduce() test reduce(): print list to the console again and see if every element occurs once. Note that the reduced list can contain no more than 9 rectangles

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!