This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

alphabetical order

johnathan smith
Posts: 21
  • Mark post as helpful
  • send pies
  • Report post to moderator

forgive me as I have recently posted a topic about the same subject
however i feel it is best to start again to clear the situation up

this situation
i have a class called Person - this class records and returns firstname, surname, age and height of a person

i have a class called Player - this class records and returns information gamesplayed etc. it also inherits from Person.

i have a class called club this Class contains an ArrayList of players and the class also contains add and remove methods for the ArrayList.

i have a class called main which deals with printing out the information of the players

the problem
i want to implement the Comparable Interface in the Person and Player classes so that the players are printed out in alphabetical order.

if somebody is able to offer any help on how to do this I would much apprecaite it.

i will provide code if it would act as a help

many thanks
marc weber
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
Why are you starting over? In your previous post, you already had an implementation for compareTo...

You said, "everything still prints in the order i create the objects (i.e. not in alphabetical order)." And Garrett Rowe replied, "You should probably post the lines of code where you instantiate and sort an array or list of Player objects." Garrett is helping you focus on where the problem really is, so I encourage you to go back to that thread and pick up where you left off.

I know you're looking for a fresh start, but this new post is just taking a step backwards and forcing us to duplicate work that's already been done, starting with rewriting a method that's probably working fine.

You were on the right track -- and getting good help -- in your previous thread. That's the best place to get this straightened out.
    Bookmark Topic Watch Topic
  • New Topic