CST 131 -- Test #4

Preliminary specification
SUBJECT TO CHANGE

Beginning with the second form (to create "county lists") specified for Test #3 (takehome),
make the following changes:

Integer Array,
Create a new array of integers, parallel to the array of strings. (Global; same size as the string array.)
Add a new input textbox to the form, for inputting integers.

Modify the handlers so that, whenever a string is added to (or deleted from) the string array, they also add (or delete) the corresponding element in the intege array.
Whenever the string array is displayed (in ther list box), also display the integer. (Show the integer first, followed by a period or colon, and a space.)
Complete the SORT handler, and make it swap elements in BOTH arrays.


Sort indicators & smiley-face,
Use one or two global variables to keep track of whether or not the arrays are sorted by string value, sorted by integer value, or not sorted.
Set the indicator after sorting, and change it whenever the array might not be sorted (e.g. after reading in, after adding an element).

Also, add some sort of visual indicator to the form, to indicate whether the arrays are sorted. (Perhaps a 20-point smiley-face, which changes to a frown whenever the array is NOT known to be sorted.)



Now, add the following features:


  1. SORT by INT
    Now, add another handler for a new "SORT by INT" button, to sort the parallel arrays using the integer array as the key.

  2. Lookup by INT
    Complete the handler for the LOOKUP (by string match) button, and also add another "LOOKUP INT" button to do the same thing for the integer array.

  3. DELETE
    Add a "DELETE" button to delete the selected element (found by the most-recent LOOKUP) from each array, then slide the remaining elements downward in each array, and reduce the size by one. (Note that sorted arrays will remain sorted, when this is done.)

  4. Binary sort
    Finally, modify the two LOOKUP handlers to use a binary search function when the array is sorted, but a linear-search function when it is not.