I can not get anywhere on this project I'm tryin to do. I'm not
expecting any major help with this but any would be appreciated. The
assignment is attached. The problem I'm having is trying to set up the
class link and tel_list. I set up a class person with strings for
name, town, and number. I just don't know how to set up the classes w/
their methods (constructors and operations). I'm stuck on the
assignment operator and the add and delete operations. A little help
to get me going on this would be appreciated. Thanks!
Assignment:
This is a do-it-yourself linked list exercise. Create a class tel_list
which is a list of telephone subscribers. The data in each list entry
consists of a person's name, city (or town), and telephone number.
The data is to be maintained in order by the name of the person. It
is also to be kept in order by telephone number. The subscribers will
be linked in two different ways: in name order and in number order.
Set up a class link to store this data and some pointers to link (one
set of pointers joins people in alphabetical order, one set joins them
in numerical order) for each subscriber. Your class link should have
constructors (including a copy constructor), an assignment operator
(member), and accessors and mutators as you find them useful.
The data of class tel_list will consist of pointers to the first link
in each of the two orderings: one to the first link in alphabetical
order, one to the first link in numerical order. For methods it will
require a constructor (to make an initially empty list), add (which is
given a link to insert in the list), delete (which is given a person's
name and city and must remove their link from the list), and two
versions of print. One version prints the list in alphabetical order;
one prints it in numerical order.
You will also need two methods to find a link since you must be able
to search either list. It is possible to name them both find and
distinguish them by the nature of their arguments (the name in one
case, the telephone number in the other). To either delete a current
link or add a new link you need to search for the proper location in
both orderings.
You may set your list up with either forward links only for both
alphabetical and numerical ordering or you may set up forward and
backward links for both. Your choice clearly affects the way your
methods are implemented.
In the text class link is entirely private and declares list (and
listIterator) as friends. This doesn't seem to work with your
compiler (!) and the easiest solution is to make your class link
entirely public. Do not access links directly in your main program.
The only mention of links, their functions, and their data should be
in the class list and its members.
The program using these classes will consist of a loop reading
commands and data to manipulate the list. Some sample data (with
explanations) might be
A A - add to the list
Ferguson Orono 581-3930
A
Baron Orono 866-2103
..
..
..
P P – print the list (names, cities, and numbers) twice: once in
order by name, once in order by number
A
Mittkind Bangor 947-4397
D D – delete the node whose person and city follow
Pritchard Veazie
A
Xenophon Stillwater 827-9000
Remember, errors are possible. You might be told, for example, to
remove a node with a given name and city, but the person cannot be
found. Your program should take some reasonable action in these cases
and continue to the next piece of data.
Create any additional methods you find useful for these classes. The
data is in the data folder under the name tel_list.dat
Keep your list and link classes simple – you do not need anything near
the complexity of the library link and list classes. Links with only
forward pointers are sufficient, for example. You do not need a
separate iterator class. Any function that needs to move through the
list can have its own loop within itself.
expecting any major help with this but any would be appreciated. The
assignment is attached. The problem I'm having is trying to set up the
class link and tel_list. I set up a class person with strings for
name, town, and number. I just don't know how to set up the classes w/
their methods (constructors and operations). I'm stuck on the
assignment operator and the add and delete operations. A little help
to get me going on this would be appreciated. Thanks!
Assignment:
This is a do-it-yourself linked list exercise. Create a class tel_list
which is a list of telephone subscribers. The data in each list entry
consists of a person's name, city (or town), and telephone number.
The data is to be maintained in order by the name of the person. It
is also to be kept in order by telephone number. The subscribers will
be linked in two different ways: in name order and in number order.
Set up a class link to store this data and some pointers to link (one
set of pointers joins people in alphabetical order, one set joins them
in numerical order) for each subscriber. Your class link should have
constructors (including a copy constructor), an assignment operator
(member), and accessors and mutators as you find them useful.
The data of class tel_list will consist of pointers to the first link
in each of the two orderings: one to the first link in alphabetical
order, one to the first link in numerical order. For methods it will
require a constructor (to make an initially empty list), add (which is
given a link to insert in the list), delete (which is given a person's
name and city and must remove their link from the list), and two
versions of print. One version prints the list in alphabetical order;
one prints it in numerical order.
You will also need two methods to find a link since you must be able
to search either list. It is possible to name them both find and
distinguish them by the nature of their arguments (the name in one
case, the telephone number in the other). To either delete a current
link or add a new link you need to search for the proper location in
both orderings.
You may set your list up with either forward links only for both
alphabetical and numerical ordering or you may set up forward and
backward links for both. Your choice clearly affects the way your
methods are implemented.
In the text class link is entirely private and declares list (and
listIterator) as friends. This doesn't seem to work with your
compiler (!) and the easiest solution is to make your class link
entirely public. Do not access links directly in your main program.
The only mention of links, their functions, and their data should be
in the class list and its members.
The program using these classes will consist of a loop reading
commands and data to manipulate the list. Some sample data (with
explanations) might be
A A - add to the list
Ferguson Orono 581-3930
A
Baron Orono 866-2103
..
..
..
P P – print the list (names, cities, and numbers) twice: once in
order by name, once in order by number
A
Mittkind Bangor 947-4397
D D – delete the node whose person and city follow
Pritchard Veazie
A
Xenophon Stillwater 827-9000
Remember, errors are possible. You might be told, for example, to
remove a node with a given name and city, but the person cannot be
found. Your program should take some reasonable action in these cases
and continue to the next piece of data.
Create any additional methods you find useful for these classes. The
data is in the data folder under the name tel_list.dat
Keep your list and link classes simple – you do not need anything near
the complexity of the library link and list classes. Links with only
forward pointers are sufficient, for example. You do not need a
separate iterator class. Any function that needs to move through the
list can have its own loop within itself.
Comment