Lab 9

Sorting

0. Get the supplied code to run.  This code should have an int array that is created with some random values in it, such as:

    int[] values = {3,8,12,9,16,1,10,13,1,5};

    Write a method to display the values in the array (to the console).

1. Implement a selection sort method to sort this array.  You may want to look at the code we discussed in class as reference, as well as the arrays section of the online notes.  Call the selection sort method to sort the array, then print it out again to show that it is in fact now sorted into ascending order.

2. Assign and step through the provided array of squares to make a new square for each array element, for a total of 10.  Each square should be of size between 5 and 25 (modify the randSize declaration and assignment to make it a number between 5 and 25, instead of between 1 and 50, as currently written).  Display these Squares in a single column, where each Square gets a 30 x 30 area in which to be displayed.

3. Write a separate selection sort method, which sorts the array of Squares.  Sort the array in ascending order by Square size, then again display the contents of the array, this time in a second column on the Canvas.

Use the files supplied below.  It should only be necessary to modify and turn in Board.java.  

Due 10/20 at 11:00 AM.