Develop an athlete class that has the persons name sport


Need help writing this program in java.

Directions:

Your task is to develop an Athlete class that has the person's name, sport, and ranking, where the name and sport are Strings and the ranking is anything that is comparable (do NOT hardcode this to an int - use generics).

You should be able to sort athletes two different ways: alphabetically by sport and if two athletes have the same sport, they should be sorted alphabetically by name or alphabetically by sport and if two athletes have the same sport, they should be sorted in decreasing order of rank.

In your main method, create five Athlete objects, add them to an ArrayList, and display them. Then sort the ArrayList by sport and name and display the sorted list.

Finally, sort the array list by sport and ranking and display the sorted list again.

Hints: Because you need to sort the Athletes in two different ways, you will probably need to both implement Comparable and make a new Comparator class.

You may need to add getter methods for the fields in your Athlete class, and it might be helpful to override the toString method to make it easier to display the objects.

output example:

Unsorted

John Doe (baseball - 3)

Sam Johnson (football - 2)

Kevin Smith (baseball - 1)

Sally Johnson (swimming - 3)

James Smith (swimming - 4)

Meagan Kelly (swimming - 1)

Sorted by sport and then name John Doe (baseball - 3)

Kevin Smith (baseball - 1)

Sam Johnson (football - 2)

James Smith (swimming - 4)

Meagan Kelly (swimming - 1)

Sally Johnson (swimming - 3)

Sorted by sport and then ranking

Kevin Smith (baseball - 1)

John Doe (baseball - 3)

Sam Johnson (football - 2)

Meagan Kelly (swimming - 1)

Sally Johnson (swimming - 3)

James Smith (swimming - 4)

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Develop an athlete class that has the persons name sport
Reference No:- TGS02873573

Expected delivery within 24 Hours