• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SortNames Requirements

 
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Barry Gaunt said
RTFRequirements again and again! Make a checklist


Requirements checklist for SortNames
Work with an ArrayList
Implement an Interface
Use I/O
=======================
Load ArrayList with Strings from text file
Show names sorted in order by First Names then Last Names
Use com.javaranch.common.TextFileIn
Use Collections for sorting
***Do not create second list
***Do not modify ArrayList except by using Collections class
Class will be called SortNames

Question: What is the possible relationship between Collections.sort and compareTo()? Or Collections and compareTo()? Or is the compareTo() method to be used somehow in a println() / loop struct as comparisons are made?
Thanks
[ May 15, 2003: Message edited by: Donald R. Cossitt ]
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DC: Question: What is the possible relationship between Collections.sort and compareTo()?
There are several flavors of Collections.sort(). Make sure you understand when you'd want to use one or the other.
 
Donald R. Cossitt
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


There are several flavors of Collections.sort(). Make sure you understand when you'd want to use one or the other.


Having done that, it is apparent that there is at least one other Interface candidate to satisfy the assignment. Is it safe to ask or say that Comparable is not it? Or in addition to the other? (Hope this makes sense, trying to be discrete is so out of character for me )
Thanks
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I recall something about a bull...
Do a search on this forum for Comparable, or SortNames, etc. and you will find several discussions on this very topic. Probably will find your answer there
 
Donald R. Cossitt
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Yeah, I recall something about a bull...


I used to think that BS was my long suit, but ol' Barry is too sharp for me. Trouble is he's been around longer.
Weeding through the searches - thanks
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Methods of an interface must be overridden (implemented) by the class that implements the interface.
 
Donald R. Cossitt
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Marilyn to question in antiquity:
Question 1) Is it correct that I can NOT write a method, which separates the names, sorts them via Collection class, and puts them afterwards together via kind of backward cut-and-paste?
Yes, as long as you don't store the reversed names into another ArrayList or array, etc.


If the project is accomplished in this manner, would this not be in violation of "implementing an Interface" in that one would not be needed? Or is it ok to Implement / Override and not use the required abstract method? Just kinda have it there for...?
[ May 17, 2003: Message edited by: Donald R. Cossitt ]
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd be interested in seeing how you'd do it without using an interface and without storing the names in a new collection.

Also, you may not need to use every method that you've overridden.
 
Donald R. Cossitt
buckaroo
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


...without storing the names in a new collection.


Well you can't. But then that is what the original question was asking - wasn't it?


sorts them via Collection class, and PUTS THEM AFTERWARDS together via kind of backward cut-and-paste?

 
hired gun
Posts: 250
MS IE Oracle Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe this will help you, I think it helped me
Cattle Drive thread
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic