Lab 16 for May 20, 2003
Individual lab - Hand in on paper (you can print if the printer works,
but do not count on that
working)
For today you are to help your teacher help replace the ugly apvector
class with an equally ugly apvector based on linked lists... In
class his evil plans began with his object oriented linked list.
Today you are to further extend this to give more of the functionality
afforded to apvectors (though this one will only store integers)
You are to implement the following add-ons to the existing code located here and here
Write two new constructors:
one will take a single integer argument, and this will create a linked
list with that many items involved. You can have the value of the
data item be whatever you please.
The other will take two integer arguments, and this will create a
linked list with that many items all of them set to a particular
value. Remember, to ensure the first node's data is set the
same value.
You are then to implement a copy constructor and a concatenate (+=)
operator. Be sure to NOT simply assign the linked lists to each
other. You must be sure you are CREATING a new list with the same
data as the existing list or in the case of += creating a new node for
EVERY node in the list on the right hand side argument. You are
allowed, and in fact, encouraged to use the existing methods in the
class to make your work easy. In fact, NONE of these methods need
be more than 15 lines of code. (usually much less)
the additions to the .h file in the class definition are as follows:
llist(int size); // new constructor 1
llist(int size, int defaultvalue); // new
constructor 2
llist(llist &rhs); // copy constructor
llist& operator += (const llist &rhs); //
concatenate operator
Also, only hand in the implementation of those 4 methods (and any
helper functions you may write) including the requisite pre and post
conditions and comments.