beginner help
hi
just a small queery here im having a bit of trouble here
i have a class called Club which contains an arrayList of Players, it also contains add and remove methods for players in the arrayList.
I have a written a class containing a Comparator comparing the batting average of players which is stored in a called class Player.
The code for the comparator is below.
I want to you if it is possible to implement a new method in the club class called add which passes a Player and Comparator hence writing a main program printing information about the players in decreasing order of batting average.
any hints, tips or pseudo code would be much apprecaited.
thanks
publicclass BattingAverageComparatorimplements Comparator<Player>
{
publicint compare(Player player1, Player player2)
{
if(player1.getBattingaverage() < player2.getBattingaverage())
{
return -1;
}
if(player1.getBattingaverage() > player2.getBattingaverage())
{
return 1;
}
else
{
return 0;
}
}
}

