First, this is homework, but no, I'm not asking for anyone to do any code for me. My course start date isn't for another month (it's online), so I can't ask for clarification. I thought I'd see if this method description even makes any sense in the eyes of the community.
I had to create a class AddressBook
that contains contact information such as someone's first, middle, and last names, their phones numbers... etc. (The class should really be called AddressBookEntry
to make sense).
After creating the class, step 2 was to create a static method with the signature:
public static String compareNames(String name1, String name2)
And the only description of what they want is:
Using the get and set methods, create a comparison method compareNames(name1, name2) that compares the first, middle, and last names of strings name1 and name2. Assume that name1 and name2 follow the following format: “FirstName M. LastName”.
To me, this doesn't make any sense. I've never seen a comparison method return anything other than a boolean
or an signed int
for inequality comparisons. The only thing I could think of was returning something like the first chunk of the second name that matches the first; but that seems rather arbitrary.
Maybe I'm missing something here though. How should I interpret this question?
The course has a general discussion board that I can read but not (yet) post to. Someone posted the exact same question as me, and someone else replied with a message from the tutor:
It will return a string that contain the result of comparison between name1 and name2.
Turns out it's not a typo; but that "clarification" didn't really help.