2.3  Understanding Data: Unions of Classes

The class of data that represent pets in the first part is not really sufficient. We have no idea what kind of pet the animal is. We would like to distinguish between the following kinds of pets:

We need a data definition for pets that covers all these options. Of course, we still keep track of the name of the animal and of its owner.

  1. Make examples (in English words) of at least one of each kind of pets.

  2. Draw a class diagram for the class hierarchy that represents this information about pets.

  3. Design data definitions for this data in the Beginner ProfessorJ language.

  4. Convert your examples to data.

2.4  Representing Self-Referential Data

We want to trace your ancestry. Write down the name of your mother and your father, for each of them the name of their mother and father - as far as you can trace your ancestors. Write unknown when you no longer know the names. Organize your ancestor information into a tree-like structure - you are the root, your parents are the two branches, and each set of parents represents the two branches above their child. (You do not need to use actual names — feel free to make up the names of your ancestors — but go back to at least one great-grandparent.)

Design data definition that can be used to represent this information and then convert the information about your ancestry into data.