Question: Write a Java program that: 1.Has a new (application) class,L6_232XXxx,that contains an implementation of the static sort() method described on p. 247 but using generics

Write a Java program that:

1.Has a new (application) class,L6_232XXxx,that contains an implementation of the static sort() method described on p. 247 but using generics similar to the

binarySearch() method in the Arrays class on p. 247

2. Method signature: public static void sort (AnyType [] arr, Comparator cmp)

3.Implement the sort()method using actual code (i.e. not via an API method) that will sort the contents of arr according to the Comparator

objects logic. The sort used must be Selection Sort (yes there are other fine, fine sorts , I want to see you implement this one.)

4. Write a static method in that same class to display the contents of any object array. The method will take in the array plus an integer

parameter corresponding to how many items are displayed on a line. Make sure it newlines at the end of the last line regardless of how

many items are on it.

5.Add a main()method to the same class that will:

a. Generate a random array of Point(Java.awtversion)objects

i. Have x/y values range-100 to 100 (inclusive)

b.Display the original array, sort it, then display the sorted array.

i. Run the test twice with two different comparators-one for ascending order, one for descending. (put the comparator classes in this same singular class.)

ii. Criteria for sorting Points for this lab is by x-value, with y- value as a tie-breaker.

iii. The standard toString() is acceptable for output.

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!