Lab 12

Problem 1: Create the following class hierarchy.

  • Abstract Class Contact that contains a person's name.
  • Class Friend derived from Contact that contains the date of birth, phone number, and address.
  • Class Acquaintance derived from Contact that contains the phone number.
  • Class Colleague derived from Contact that contains the phone number, the company they work for, and the address.
  • Class AddressBook that contains multiple elements of type Contact.

The AddressBook class has the following functions:

  • A method to search for a contact by name.
  • A method that returns a list of friends (contacts of type Friend).
  • A method that deletes a specific contact by name.
  • A method that adds a specific contact.

For creating the classes, UML techniques will be used.

For the contact type (Friend, Acquaintance, and Colleague), an enumeration will be defined (also using UML methods) to describe this type of data.

Also, create code in main.cpp to illustrate how these components work.