GeeCON Prague 2014*
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


JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "SortNames" Watch "SortNames" New topic
Author

SortNames

Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Am I understanding past conversations correctly, that we are, in fact, allowed to change the ArrayList of names, if by change we mean reorganize (sort differently)?
It would seem others liked using an Iterator. Are we supposed to use this? I just loop through the ArrayList with a simple for loop, getting one component after the other. Would it somehow be more efficient to use an Iterator?
Am I missing the point entirely, and we actually aren't supposed to reorganize the original ArrayList, but use rather some semi-complicated (and I'm sure not efficient) construct with an Iterator, Enumeration, etc. to display the names in the specified orders? Of course, that would seem to fly in the face of the "use Collections" requirement, but this wouldn't be the first time that the instructions would seem to be there more to fool us to do it wrong in order to be corrected - I don't think this is the case this time.
Oh yeah, and I'm really loving this Cattle Drive! It's the greatest!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Dirk Schreckmann:
Am I understanding past conversations correctly, that we are, in fact, allowed to change the ArrayList of names, if by change we mean reorganize (sort differently)?


The Collections method that you use is allowed to change the ArrayList of names. You are not allowed to store the changed list in a new ArrayList.

It would seem others liked using an Iterator. Are we supposed to use this? I just loop through the ArrayList with a simple for loop, getting one component after the other.

Either way is acceptable.

... but this wouldn't be the first time that the instructions would seem to be there more to fool us to do it wrong in order to be corrected

You are welcome to suggest wording for any of the assignments which would make them clearer for future students. I believe that it was Matt who already has made a suggestion (which has been implemented) for this particular assignment, and you still have questions.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Thanks for the clarifications.
I did read the previous suggestions for rewording the specifications, but the suggested changes appear to not have been made. It still says:
"Show the names sorted in order of first name and then by last name without modifying the strings or the ArrayList. ... Use the Collections class for sorting. "
So, the obvious confusion is: Which is it, don't modify the ArrayList and use Collections which changes the ArrayList or ... huh?"
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10

Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Do not create a second list with the names in a different order. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Your class will be called SortNames.

Better? Suggestions?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Very clear. Of course if you still wanted to say something about not modifying the components of the ArrayList (especially when considering sorting by last name), that'd probably save one or twenty nitpicks.
Looks good.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10

Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not store modified names in the ArrayList. Your class will be called SortNames.

Italicized section = proposed changes. Better? Suggestions?
[ May 03, 2002: Message edited by: Marilyn deQueiroz ]
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Definitely clarifies what a good portion of the student population have gotten hung up on.+
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Perhaps "do not modify the ArrayList or its contents except by using the Collections class to sort it."


"I'm not back." - Bill Harding, Twister
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not modify the ArrayList or its contents except by using the Collections method(s). Your class will be called SortNames.
Like this? Is this clearer than "Do not store modified names in the ArrayList."?
[ May 03, 2002: Message edited by: Marilyn deQueiroz ]
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Collections class sounds better than Collections method(s).
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Load an ArrayList with Strings from a text file of names. Show the names sorted in order of first name and then by last name. Use com.javaranch.common.TextFileIn to read the names. Use the Collections class for sorting. Do not create a second list with the names in a different order. Do not modify the ArrayList or its contents except by using the Collections class. Your class will be called SortNames.

Yes, I like this better.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Yup, that looks like the one
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Nice and clear.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Nice improvement!
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20586
    ∞

Sounds good to me. M, make it so! Engage! Warp 9!


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Josue Cedeno
Ranch Hand

Joined: Feb 06, 2001
Posts: 71
Thanks for the clarification! Not bad timing considering it's the next assignment on my list.
Wow, Paul Wheaton droppin' a note in the good ol' Java College! (This is almost like meeting Obi-Wan Kenobi)
 
GeeCON Prague 2014
 
subject: SortNames