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

  1. 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.
  2. Other applications will want to send correspondence or just cite the person's name in the usual English form,
    e.g. Rush Hudson Limbaugh.
  3. Although most English names have three parts, some may have more (George Herbert Walker Bush) and some may have less (Cher).
  4. Any part of a name may contain an embedded blank and need not begin with a capital letter: Olivia de Havilland
  5. 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.
  6. 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

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.