CS120
Lab #12
Due at the end of lab.
For this lab you will be creating your own linked list.
Begin by creating a node class, which should contain the following:
-
A private string variable called name.
-
A private integer variable called ID.
- A private node pointer called next
- A public set function that takes a string, an integer, and a node pointer and
sets the name, ID, and next variables.
- A public, recursive print function that prints every element in the linked list.
- A public, recurisve search function that takes an integer as an argument and
searches a linked list for the matching ID. It should return a string -
the name that matches the ID. Or return an empty string "" if the ID is not
found.
The main code node to use the node class to do the following:
- Create a variable called head that is a pointer to a node.
- Use the head variable and the new command to create a linked list
with 4 elememts in it each with a name and ID:
- Tom 54321
- Sally 12345
- George 67890
- Grace 098765
- Once the list is created, print it using the print() function in the node
class.
- Test whether the search() function works for both ID's in the list
and ID's not in the list.
Turn in:
Your code and sample output showing that the list is printed and that
the search function works..