Hi,
I am trying to sort out a Stack of Dvd objects, I have a Dvd class which implements Comparator<Dvd>. The following code snippet below is the method that overrides the compare() method:
In another class I have a main method which tests this statement which I am also trying to implement it into a bubble sort method:Code:public int compare(Dvd dvd1, Dvd dvd2)
{
return dvd1.getTitle().compareTo(dvd2.getTitle());
}
Im not going to go any further with the sorting code until I have the if statement correct, which I have called the overrided compare method in Dvd to compare two objects which is running in two for loops to compare all Dvds in the Stack dvds. ?Code:for(int x=1;x<10;x++)
{
for(int y=0;y<10-x;y++)
{
if(Dvd.compare(dvds(y), dvds(y+1))>0)
{
}
}
}
Thanks
