Hi,
What I'm trying to do is come up with a class that can do a number of things with an ArrayList of names:
1) Sort the ArrayList telephone directory style (last name, middle name, first name)
2) Sort the ArrayList using usual English form (first name, middle name, last name)
3) Be able to handle all types of names ( 1
word names such as Cher, multiple word names such as George Herbert Walker Bush, and names with embedded blanks such as Olivia de Havilland)
4) Make sure the name can fit on a standard mailing label (48 characters).
This is what I've done so far:
I made an ArrayList of objects, and each object takes a firstName
String, middleName String, and lastName String. (For names like Cher, i left the middle and last name as blanks:" ".
I then made a toString method that returns lastName, middleName, and firstName (in that order). With the collection sorting ability of ArrayLists, I think I've taken care of #1.
This is where I'm stuck. How can I get toString to now satisfy #2 by returning firstName, middleName, lastName (instead of lastName, middleName, firstName)?
Am I on the right track, or is there a much better way to do this?
Any help would be greatly appreciated