Due Date: Monday, October 25, 2010, or Tuesday, October
26, 2010, depending on the day of your lab.
Objective: The goal of this assignment is to practice linked lists.
Background: During the winter holidays, people usually
visit their friends and relatives. Let us use lists to help
organize a sequence of such trips.
Assignment: The elements of your list are objects
representing a friend or a relative. Each such object should
contains three fields:
- the name of the main person in
the household,
- their relation to you (e.g., "cousin",
"friend", etc.), and
- the number of people in the household
-- i.e., the number of gifts that you need to bring.
Write methods:
- for starting such a list,
- for inserting a new person to the list,
- for deleting a person from the list,
- for searching whether a given person is on your list,
- for printing the total list of people to visit, and
- for computing the total number of gifts that you need to buy.
In the main program, test your methods by
filling in information about at least five different people to visit,
and by printing the resulting list. To test insertion and deletion, add
our favorite TA to the list, show that you can search for
this TA, then delete the poor TA from the list :-).
For extra credit: write your method by using the ADT list
and check that it works both for a linked list and for an array
implementation of this ADT.