L10b

Due by the end of this meeting

Starter Files:


SUBMIT   /   Submission Summary

Restricted Generic Types

Activity 1
Make a program called Lab10 that creates a List of exactly seven Rectangle objects with widths and heights between 1.0 and 10.0.
One way to make a number between 1 and 10 is
double number = 1.0 + 9.0 * Math.random();

Print them out, one per line using a method printRectangles.

For example, your output might be

- 5.3x3.4 Rectangle - 9.4x1.4 Rectangle - 9.0x2.7 Rectangle - 2.8x7.7 Rectangle - 6.4x4.4 Rectangle - 3.9x1.3 Rectangle - 3.3x2.0 Rectangle
Activity 2
Extend the program above by using the methods from Quick to find the median height and median perimeter of the Rectangles you generated. Print out the whole List one element per line after each operation, then report the median value.

Note that the median value for a list of length seven is the element in position 3 when the list has been sorted.

Do not sort the whole array. There is a method in Quick that you can use to make sure the element in the middle of the List is the median value for the List.

Your output should look like this (but of course with different numbers):

Original List - 2.4x5.6 Rectangle - 6.9x4.9 Rectangle - 7.3x8.2 Rectangle - 7.1x3.7 Rectangle - 5.7x4.5 Rectangle - 3.5x3.8 Rectangle - 6.9x7.9 Rectangle For the median height: - 7.1x3.7 Rectangle - 3.5x3.8 Rectangle - 5.7x4.5 Rectangle - 6.9x4.9 Rectangle - 2.4x5.6 Rectangle - 6.9x7.9 Rectangle - 7.3x8.2 Rectangle The median height is 4.862559792975944 For the median perimeter: - 2.4x5.6 Rectangle - 3.5x3.8 Rectangle - 5.7x4.5 Rectangle - 7.1x3.7 Rectangle - 6.9x4.9 Rectangle - 6.9x7.9 Rectangle - 7.3x8.2 Rectangle The median perimeter is 21.566929104626116
Your grade will be based on the following rubric:

Submit this/these files:


SUBMIT   /   Submission Summary