Goals
- to practice using C++ pointers and linked lists
Problem Specification
The listPlay function in listPlay.h stores input values in a list,
prints the list, and then removes input values from the list,
and prints the list.
The function is templated to handle any object with assignment, copy,
default values, and a comparison for equality.
Each line of input will consist of multiple values of the templated type. Use the first line of input to construct a LineScanner object. Extract values and place them in the list. Print the list. Then use the second line of input to construct another LineScanner object. Extract values and remove them, if they exist, from the list. Print the list.
The existing implementation uses a vector to store the list. The version you deliver should have the same functions and functionality but must use a linked list built using the provided templated Node class in Node.h
You will turn in your revised listPlay.h file as the list assignment. It must work (compile and execute cleanly) with the files provided with it in ~katz362/support/list. But you will submit only listPlay.h as revised to use a linked list.
The Files
Node.h is the Node class we've used in lecture.
LineScanner.h takes a string as its construction parameter and provides items of the desired type through the nextValue function.
listPlay.h is a utility to test a data structure by filling it with values, printing the contents, and deleting some of its values. Currently uses a vector to store the list. Modify this to build and use a linked list instead of a vector. This is the only file you change and is what you'll submit.
main.cpp calls listPlay with different types.
Makefile builds the files into an executable; type make to build.
Suggestions
Copy the files from ~katz362/support/list.
In the terminal,
compile your project with
c++ -Wall -g *.cpp
Then use ./a.out to execute it
(note the dot before the slash).
Copy listPlay.h to original.h so that you can refer to the original but make the changes you need in listPlay.h.
Comment out the removing parts and concentrate on building the list. Then implement the removing.
Look at the examples. You don't have to sort the list. Just insert at the front.
Draw a lot of pictures of what needs to happen.
Be sure to keep your prototypes matching your implementations.
All of your changes will be in listPlay.h. Don't change the other files.
Before you submit it, compile and run it from the command line/terminal.