This lab is due by Tuesday, March 29, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.
Instructions
We will begin refactoring our LinkedList operations from a structured procedural style to a more Object-Oriented approach. This will occur over the next sequence of labs, so be sure to keep the end point of each lab as a snapshot.
Start by copying the Node.h
header from Lab4B and
placing it in this folder. Now create a new file called LinkedList.h
that will store our Linked List class
declaration. Note the naming scheme of our files now. We're using the PascalCase (UpperCamelCase) to denote this
file contains a class declaration (since it's a header) and the name of the class is LinkedList.
The Class Shell
Begin by creating the LinkedList class shell. This class will represent a LinkedList structure. It's contained state will be the actual linked list and it will contain the methods to manipulate that state - the linked list.
Data Members
We'll start by adding three data members (do not initialize them at this time, just declare them):
- A pointer to the head Node of the list (be sure to include the Node header file!)
- A pointer to the tail Node of the list
- An unsigned integer to track the size
Methods
Now we'll add the function prototypes for our class methods. Create the following prototypes to build out the LinkedList interface:
-
Name: makeNodeForValue
Input: an integer value
Output: a Node pointer
-
Name: pushFront
Input: an integer value
Output: none
-
Name: pushBack
Input: an integer value
Output: none
-
Name: popFront
Input: none
Output: an integer value
We'll worry about their implementations next time. For now, we're just performing the setup necessary. You can likely guess what these functions will do based on their name. Take note of the terminology we are using to add or remove elements to the LinkedList. These should be familiar. This will be consistent terminology (push/pop) that we use with our data structures.
Be sure to save a snapshot of your code at this point. We will make a copy to start Lab4D as we continue to modify and build out our class.
Lab Submission
Submit your Node.h, LinkedList.h
file(s).
You will submit your solution to this lab with the rest of Set4. Detailed instructions for doing this are posted in Assignment 4.
This lab is due by Tuesday, March 29, 2022, 11:59 PM.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.