aspose file tools*
The moose likes Cattle Drive and the fly likes SortNames.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "SortNames.." Watch "SortNames.." New topic
Author

SortNames..

Nathan Leniz
Ranch Hand

Joined: Nov 26, 2006
Posts: 132
So I've taken a peek at SortNames while waiting for OOP2 to come back from nitpicking, and...

I've made a solution that works, but I must say that initially it was very confusing. Perhaps it's because I've been on an extended break. I found the first part of the assignment to be pretty straightforward.

But wow, the second part threw me for a loop for a bit.

I found this link pretty helpful, but I still have some questions.

In the assignment, it states Use the Collections class for sorting so I think it's safe to say here that Collections.sort(somethingToBeSorted) is where we should go? Now, looking at the API, anything to be sorted must implement a certain interface.

However, it's the argument after the "somethingToBeSorted" that's doing the real work on the second go round, but in order to do this....

I'm really really hoping that the somethingToBeSorted doesn't have to be an exact representation of the things in the file to be read in? Is it ok to give those things certain attributes, and then stuff them into somethingToBeSorted?

Or am I way way off track?

If this made no sense at all, I apologize, and I'll try to reword it. Trying to be vague enough not to give anything away without being too vague.

Edited out a previous assumption that in experimenting I found to be completely wrong. That assumption was the inherited method from needed interface was not needed. Turns out, it really isn't needed, but if you use it the way it's meant to be, you don't have to use two different workhorses, and save yourself some time typing. Ah, the joys of learning.
[ May 16, 2008: Message edited by: Nathan Leniz ]

The very existence of flamethrowers proves that at some time, some where, some place, someone once said to themselves "I'd really like to set those people on fire over there, but I just can't get close enough".
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
Originally posted by Nathan Leniz:
I'm really really hoping that the somethingToBeSorted doesn't have to be an exact representation of the things in the file to be read in?


I'm afraid so. somethingToBeSorted is exactly the same thing in both cases.

The assignment says:
Do not modify the ArrayList or its contents except by using the Collections class.

But on the positive side, there is no end to the wonderful things you can make that other parameter do.

It can take what is in your entirely unaltered somethingToBeSorted and put it through a grinder.. if it helps you get what you need.
Nathan Leniz
Ranch Hand

Joined: Nov 26, 2006
Posts: 132
Not sure how I got off on the tangent that I did, but I think I'm much closer to the right course now. A total of... 2 variables, 3 methods, and roughly 40 lines of code gone!

Thanks for the info Katrina!
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
I bet you learned a great deal on that tangent

Sometimes it's so easy to overcomplificate (as a friend of mine used to say).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SortNames..