Project 4 - Linked Lists

  < Previous  Next >

Objectives

  1. Write a LinkedList class
  2. Write a constructor and destructor

Assignment

For this project, you will complete a C++ program in CodeLite to store hospital patients. (Create a new project using the 2170 template.) The driver code is located in LinkedList-main.cpp. (Do not modify this code.) Your assignment is to write the declaration for the LinkedList class in a header file (LinkedList.h) and it's implementation (in LinkedList.cpp) such that the driver code compiles and produces correct output. Your LinkedList class needs to use a pointer-based linked list. Consequently, it needs an appropriate constructor and destructor (among others). For your insertion method, insert at the beginning of the list.

The driver code processes the following commands:
A <NAME> (admits patient NAME to the beginning of the list)
D <NAME> (discharges patient NAME if NAME is in the list, silently continues otherwise)
F <NAME> (prints patient NAME if found in the list)
V (visits all patients and displays their names in list order)

You can use the following input files for this project:

Example

Your program should match the following output exactly: (user input in bold text)
Please enter the input filename (or simply press return to use project4-testA.tab)
Importing patients from project4-testA.tab ...
There are no entries in the list to display

Sophia is not found in the list

Displaying the single entry in the list:
Sophia

Sophia is in the list

There are no entries in the list to display

Sophia is not found in the list

Displaying all 5 entries in the list:
Lucas
Olivia
Aiden
Emma
Jackson

There are no entries in the list to display

Submission

Before submitting this assignment, make sure that DEBUG is set to false and that there are no compilation errors. If there are errors, fix them before submitting. You may need to edit and compile your program multiple times before it compiles successfully. Verify that the output is correct. Once you are able to successfully run the program with the correct output, you are ready to submit the program. Submit your LinkedList.h and LinkedList.cpp files and your completed rubric using the handin program.
handin  project4  LinkedList.h LinkedList.cpp rubric4.txt
To verify your submission, type the following in a terminal window:
handin  project4

Rubric:

Points       Item
----------   --------------------------------------------------------------
_____ / 15   Documentation:
             Header comment block at the beginning of each file with:
             + Your full name
             + Date(s) code was written
             + Description
             Comments explaining the role of each variable and major section of code
             
             Program solves the assigned problem using methods described in program description:
_____ /	10   + LinkedList class
_____ /	 5   + LinkedList constructor
_____ /	15   + LinkedList destructor (all nodes are dellocated)
_____ /	10   + LinkedList::insert()
_____ /	18   + LinkedList::remove()
_____ /	15   + LinkedList::print()
_____ /	10   + LinkedList::printAll()
_____ /  0   Program compiles without errors
_____ /  0   Program executes without crashing
	     
_____ /  2   Completed rubric (estimates for each line, including hours spent)

_____ /100   Total

_____  Approximate number of hours spent

Notes

  1. If you want to match my output exactly, then run the following on ranger:
    g++ LinkedList-main.cpp LinkedList.cpp -o project4
    echo "/nfshome/hcarroll/public_html/2170/private/projects/project4-testA.tab" |  ./project4  &>  output.txt
    diff /nfshome/hcarroll/public_html/2170/private/projects/project4-answerKeyA.txt  output.txt
    If the two files match exactly (which is what you want) then there should be NO output from diff. If diff shows one or more differences, fix them and run it again. To get side-by-side output (with the answer key on the left and your output on the right), replace the last line with:
    diff  --side-by-side  /nfshome/hcarroll/public_html/2170/private/projects/project4-answerKeyA.txt  output.txt
    For details about interpreting the output of diff, see the Using diff section on the Misc. webpage.

Challenge

For an OPTIONAL challenge, do one or more of the following:
  1. Write a copy constructor, move constructor, copy assignment operator= and the move assignment operator=.