Goals
- to practice using C++ pointers and linked lists
- to change the underlying implementation of an existing program
Overview
The program reads in pair of input lines containing different types of values.
It inserts the items on the first line into a list.
It removes the items on the second line from the list.
The list is currently implemented with a vector.
You will modify it to be implemented with a linked list.
All of your changes will be in the listPlay.h file. The program uses various other classes. Use them, but don't modify them. You submit only listPlay.h.
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.
Suggestions
Copy the files from ~katz362/support/list keeping them in their own directory.
In the terminal,
compile your project with
c++ -Wall -g *.cpp
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.
Use /* and */ to create block comments.
Look at the examples. You don't have to sort the list. Just insert at the front. Or use a tail pointer.
Draw a lot of pictures of what needs to happen. Pictures really help.
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.