Question: Lab 3 : Linked Lists Attached Files: File stuff 1 . txt File special 1 . txt File special 2 . txt File special 3

Lab 3: Linked Lists
Attached Files:
File stuff1.txt
File special1.txt
File special2.txt
File special3.txt
File special4.txt
File special5.txt
COSC 2436 Programming Fundamentals III
Lab 3 Linked Lists
You will write a program to process the lines in a text file using a linked list ADT and raw pointers.
Node class
You will create a class Node with the following private data attributes:
category the category of the line
line line from a file (string)
next -(raw pointer to a Node)
Put your class definition in a header file and the implementation of the methods in a .cpp file.
Follow the style they use in the book of having a "#include" for the implementation file at the bottom of the header file.
You will have the following public methods:
Accessors and mutators for each attribute
Constructor that initializes the attributes to nulls (empty string or nullptr for the pointer)
Destructor
LinkedList class
You will create a class LinkedList with the following private data attributes:
headPtr raw pointer to the head of the list
numItems number of items in the list
Put your class definition in a header file and the implementation of the methods in a .cpp file.
Follow the style they use in the book of having a "#include" for the implementation file at the bottom of the header file.
You will have the following public methods (you can have more if you need to):
Accessor to get the number of items in the list
Constructor that initializes numItems to zero and headPtr to nullptr
Copy constructor
Add a node this method will take as input two string values the category and the line. It will create a node object and set the attributes. Then it will put the node in the linked list in alphabetical order grouped by category. The categories will not be in sorted order they will be in the order they were encountered in the file, but the lines within each category will be in alphabetical order. You will not add the items then sort them later you MUST put them in the correct spot one time. You will not use a vector for any of this process - you are to only process your linked list.
toVector returns vector with the contents of the list which will be a string category followed by a string line of text from the file. You will use only the push_back method to get the strings into the vector.
Destructor
Data File
The data file contains records with two fields a category and a line of text. Each line of text is categorized into one of an unknown number of categories.
Client program
Your program will ask the user for the file name, open the text file , read each category/line record and store into two strings. Make sure the file opened correctly before you start processing it. You do not know how many records are in the file so your program should read until it gets to the end of the file.
Your program will invoke the add method on the linked list object passing the category and line of text for the current record.
It will then display the contents of the list (the records that were read from the file). Display the category once with all of the lines in that category indented.
You will use a class method toVector that puts all of the category/line pairs into a vector and returns it to the program that will display it.
Add Method Details
Your add method will create the node, set the values and put the node in the list at the correct location. The lines of text should be grouped by category and in ascending order within each category. Put the categories into the linked list in the same order they were first encountered in the file. The program will continue to do this until the end of the file has been reached.
To summarize
Your client program will do the following:
Read file name from user
Display the category/line pairs from the file using the class method toVector to get this information.
I have attached files you can use to test your program. Blackboard handles files in a strange way sometimes. You may not be able to directly download the files, but you can open them, copy and paste the contents into a notepad file and save that file.
You will write all of the code for processing the linked list - do not use any predefined objects in C++. You do not need to offer a user interface beyond asking for the file name and displaying the contents of the list using the toVector method.
You will submit the following:
All of program source and header files compressed into a zip file. Do not include any executable or project files only .h and .cpp files.
Name your zip file lab3_Firstname_Lastname. You decide what to name the other files.
Example 1
If the file contained the following:
Name
Clovis Bagwell
Interesting
The quick brown fox jumped over the lazy dog.
Interesting
Shake rattle and roll.
Nonsense
One red bean stuck in the bottom

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!