CSCI 6620 Program 3: Sorting a List of Lines Solution

1 Goals
1. To use an input le and read it by lines.
2. To use C++ strings.
3. To implement and use a sorted linked list.
2 The Idea
The input le contains a series of lines of text.
1. Implement a main function and a Sorted List class with a helper class, Cell. That will require two .cpp les and one .hpp le.
2. Use inline functions somewhere in your class.
3. Call banner() at the beginning of your program and bye() at the end.
4. Read lines from the input le one at a time, into strings. Then insert each line, in alphabetic order, into a linked list. Finally, print the sorted list.
5. If you have handled eof correctly, the last line of the le will appear exactly once in the output.
DO NOT modify my le in order to make your program work.
6. You will be alphabetizing based on the entire line, not one letter or one word. Use the function bool operator< (const string& left, const string& right);
from the C++ string class. Please note that the prototype looks like a function, but you use it like an ordinary < operator.
3 The List Class
Review the diagrams, descriptions, and code in Lecture 3. Borrow large parts of it. Feel free to delete functions that you do not need. Implement the missing functions as they are described in the lecture.
Do not go out to the internet to borrow code. First, if it does not follow the diagrams in the lecture,
I will reject it. Second, you will never learn this stu unless you struggle with it yourself. Do not lean heavily on other students. Use them only for advice when you are stuck with debugging.
Don't act helpless { try it, and send it to me for further guidance when you are confused. But remember,
I need to see what you have attempted to know why you are confused. I can't help a person with a blank paper.
Powered by