No documentation (commenting) is required for this assignment.
This assignment is based on an assignment from "Data Structures and Other Objects Using C++" by Michael Main and Walter Savitch.
Add attach(), remove_current(), and the big-3 to the Sequence class from the last assignment. All requirements from the previous assignment are still in force. Your score on this assignment will take into consideration your work on both the previous assignment and this assignment.
Specification and Implementation
Please refer to the specification and implementation information from the last assignment.
To simplify your code, you should write two private helper functions named "copy()" and "clear()". Then your copy constructor will simply call "copy()", your destructor will simply call "clear()", and your assignment operator will include calls to both.
Note that your copy() function will NOT deallocate any memory. It assumes that the calling object is uninitialized.
Most common mistake students make on this assignment: Make sure that when you copy your list the four pointer data members point to the nodes in the new list that correspond to the nodes that they pointed to in the original list.
When writing the attach() and remove_current() functions, I prefer to start with the most restrictive cases, and then the last "else" is the general case. You can see that my insert() function (from last assignment) follows this pattern: (1) inserting into an empty list, (2) inserting at the front of a list with at least one item, (3) inserting anywhere else. For attach() I also have 3 cases: (1) attaching to an empty list, (2) attaching at the end of a list with at least one item, (3) attaching anywhere else. For remove_current() I start with an assert statement to make sure there is a current item (since that is a precondition), then the cases are (1) remove from a list that has exactly one item, (2) remove the first item in the list, (3) remove any other item. (This third case sort of has another case embedded in it: if the item being removed is the last item I have to reset tailPtr and set precursor to nullptr.)
I strongly recommend that you do not attempt to use your already existing member functions of the class when writing any of the five functions you're writing this week. It's simpler to write them from scratch.
It is very hard to get this working for all conceivable cases, and also very hard to test it exhaustively by thinking of every conceivable case. Here is a client program that tests the class pretty exhaustively. (Even this program does not test every possible case.) Note that this client accesses the class data members directly, so you'll need to temporarily make the data members public.
Here is another client program. This one is a lot harder to use as a debugging tool, but I would suggest that you run it after you have completed your class, just to make sure it doesn't fail. Please let me know if your class works with the original client but not with this one.
This second client program is the client program that we will be testing your class with. If you can't get every case to work but most of them work (as evidenced by the point total that client program reports) you can still get a pretty good score on the assignment.