Suppose I have an abstract Superclass named that is defined like this:
public abstract class Member implements Comparable<Member>
And then I have two Subclasses of Member
, defined like this:
public class Coach extends Member
public class Player extends Member
Then, I have a list of Member
, which means it contains both Coach
and Player
.
I need to sort this list, in which a coach always comes first and then come the players sorted by an identification number.
I need to implement the compareTo
method to do this. But how do I proceed, knowing that I can't implement the method in the superclass Member
, since the identification number is a property of Player
and Coach
doesn't have it?
I hope I've been clear on the problem.