¥Assume
that we want to design the data for an online
city phone book. In contrast to
our DeptDirectory example, such a directory will contain several different kinds of listings: businesses, residences, and government agencies.
¥The
entry data for such a directory is represented by using the union pattern to identify the common behavior among the various kinds of listings.
¥In
this case, the common behavior is the existence of a String name for the
listing and the String text of the listing
(given by toString()).