Assignment #2 — due February 16
This assigment will confirm your ability to design and construct a useful class.
Background
The Employee class and other examples in our textbook, use a raw String for
the name of a person. But names come in a variety of forms, even within English-speaking
societies, and much more worldwide. Furthermore, we don't feel comfortable allowing just
any string of characters to serve as the name of a person in a database. No production-quality
application would do so.
Requirements for a PersonName class
- Some applications will need to sort lists of person names in the usual (telephone directory)
sequence and to search those sorted lists,
e.g. Limbaugh, Rush Hudson.
- Other applications will want to send correspondence or just cite the person's name in the
usual English form,
e.g. Rush Hudson Limbaugh.
- Although most English names have three parts, some may have more
(
George Herbert Walker Bush) and some may have less
(Cher).
- Any part of a name may contain an embedded blank and need not begin with a capital letter:
Olivia de Havilland
- A name must fit on a single line of a standard mailing label. That is, the total length,
including embedded blanks, of the external representation must not exceed 44 characters.
- Generational suffixes (.jr, IV) should be supported
consistent with customary
English usage. Titular prefixes (Ms., Dr., Senator, etc.) should not
be supported in this class. (Why not? Where should they be handled?
Hint: The first two requirements above could specify the internal and
the external representations. (Which is which? How will your class support
the other one?)
Your Assignment
Design a flexible and usable PersonName class for the English-speaking world and
similar European cultures. Try to satisfy all of the above requirements.
Turn in
- Source code for the complete, robust PersonName class.
- Source code for a thorough test-driver, with representative test cases.
- Output from your test run(s).
Either on paper (in class) or by E-mail to the instructor.
Looking ahead
We may use this class later in the course when we study sorting and searching algorithms.