aspose file tools*
The moose likes Cattle Drive and the fly likes SortNames woes... 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 woes..." Watch "SortNames woes..." New topic
Author

SortNames woes...

Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Except for the first assignment when I was cutting my teeth and SayB, I've really enjoyed the challenge of the Cattle Drive. Now I'm really stumped!

As you can tell, I'm on the SortNames assignment. I'm befuddled (read.. I really don't get it) about the extravagence of using an interface in this exercise.

To avoid repeating a bad idea, I will not indicate what solution I suggested to Marilyn in my email to her. She refered me to this discussion forum.

I got the exercise to work, sorting by first name. I used ArrayList and Collections to get to the output (First / Last)I needed. The last name sort solution still eludes me.

I did research in this forum to see if I could glean any hints on what to do, but it was all to no avail!

I dont't understand what advantage an interface has, and, once I have the interface, what benifit it will bring. Please help!


Marcus L´┐Żubli, SCJP 1.4, CLP 5.0, SCWCD 1.4 (preparing)
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
The last name sort solution still eludes me.


Sun tutorial on Object Ordering might give you some ideas.
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
I dont't understand what advantage an interface has, and, once I have the interface, what benifit it will bring. Please help!

It's been a while since I've thought about the SortNames assignment, but maybe I can help at a real general level...

An interface usually gives you the advantage of letting you add some functionality to your class that it might not otherwise have. In this case, you need to sort by last names. Before you can sort a bunch of names, though, you need to be able to compare those names to eachother. That's where a certain interface might come in handy.

If that's altogether too vague, please say so. I think I remember some helpful conversations on this one, I'll try to dig them up...

Hang in there!
[ March 15, 2005: Message edited by: Pauline McNamara ]
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Here's one favorite on SortNames. There's a bunch of good ones out there - a quick search using 'sort names' got 'em.

Are you having fun yet?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[PM]: An interface usually gives you the advantage of letting you add some functionality to your class that it might not otherwise have.

You might add the functionality to an existing class, or you might just create a brand new class that implements the interface. Interfaces are very flexible in this respect.


"I'm not back." - Bill Harding, Twister
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29241
    
139

Marcus,
Check this thread in beginners for an example.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20271
    ∞

Here's a ditty I wrote a few years ago: http://www.javaranch.com/CodeBarn/shapes.jsp


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Interfaces allows you to code a class that won't know or doesn't care what the actual implementation class is.

So you have a

Person interface with a name and one method getName()

Now you have a Pauline, Mark, Paul, and Jim class, each of which implement the Person interface.

So if I have a class called Invitation with a method called sendInvite(Person p)

this method can call p.getName() without caring whether it is Paul, Pauline, Mark, or Jim.

Interfaces are very powerful and help open the big world of Design Patterns.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
Here's a link to one of my posts from back when I was working through this assignment: http://www.coderanch.com/t/4169/Cattle-Drive/Sorting-it-out
You are not alone!
[ March 18, 2005: Message edited by: Carol Murphy ]
Marcus Laubli
Ranch Hand

Joined: Dec 24, 2004
Posts: 116
Thanks,

Now that I have my machine running again (BIOS upgrade), I'll take a look at it.

Seems to me that others have needed help too! I"m so glad. Sometimes I feel so dumb!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SortNames woes...
 
Similar Threads
please hint me on "SortNames" !
SortNames
SortNames
SortNames..