It seems to me that your Sorts class has two versions of insertionSort(). One takes an array of ints and the other takes an array of Comparable objects. You are trying to pass in a CDCollection. You either need to overload insertionSort() to handle a CDCollection, or get the data from CDCollection into an array of Comparables, and pass that to insertionSort().
Joined: Dec 06, 2001
There are some small, but major, differences between the example and your own program. First of all, the example declares the variable "friends" as an array of Contact objects, but your "music" variable is a single instance of CDCollection, not an array. I suspect that the Contact class extends the Comparabe interface, which allows it to use the coresponding version of insertionSort(). To do something similar, you should probably create a CD class which extends Comparable. Then you just have to create an array of CD objects which you can pass to the Sorts.insertionSort() method. If CDCollection has such an array already, you may just want to have a CDCollection.sort() method which in turn callsl Sorts.insertionSort(). After that long-winded answer, the main point here is that insertionSort() takes an array as its argument, but you haven't created an array in your program. You can fix this problem with one of the suggestions provided by Greg or myself. Or if you can think of something else, please feel free to use it. Keep coding! Layne