• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SortNames..

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
reply
    Bookmark Topic Watch Topic
  • New Topic