aspose file tools*
The moose likes Beginning Java and the fly likes alphabetical order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

alphabetical order

johnathan smith
Greenhorn

Joined: Mar 30, 2007
Posts: 21
Hello

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
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
Don't get me started about those stupid light bulbs.
 
subject: alphabetical order