Lab Fourteen Solution

$30.00 $24.90

Description

Objectives:

The objective of this lab is to build your understanding of linked lists, and to prepare you to complete this week’s programming project.

After completing this lab, you should be able to

Explain what a linked list is.
Discuss some of the major issues involved with the use of linked lists.
Develop a design for a Linked List.
Study Material

Linked Lists
Lab Exercise

—————Designing a Linked List———————-

Linked List

In this lab exercise, you will develop a design for your next programming project, where you will implement and test a linked list. Refer to the textbook, the slides on Linked Lists and the supplementary material in this lab if you need some help remembering what a linked list looks like. You may also want to peek ahead at project #13.

Your Linked List project will require two classes:

The Node class: Objects of the node class will contain a three data members:

A Node* that will be used to point to the next Node in the List.
A string that contains a description of an item, for example, “bread”.
A string that contains a unit of measure for this item, for example “loaves”.
An integer value that contains the number of units of this item that you want to buy.
You should provide the necessary constructors, getters and setters for the Node class.

The List class: You need an object of this class to head the list. This class has three data members:

A Node* that points to the first node in the list. Initially this pointer should be NULL.
A Node* that points to the last node in the list. Initially this pointer should be NULL.
An integer that contains the number of nodes in the list.
You should provide the following functions in your List class:

A default constructor that creates an empty list object.
A push_back function that takes a Node* as a parameter and adds the node pointed to by the pointer to the end of the list.
A push_front function that takes a Node* as a parameter and adds the node pointed to by the pointer to the front of the list.
A pop_back function that removes the last node from the list, and returns a pointer to this node. Important, do not delete the node in this function. Simply unlink it from the list.
A pop_front function that removes the first node from the list, and returns a pointer to this node. Important, do not delete the node in this function. Simply unlink it from the list.
A getFirst function that returns a pointer to the first node in the list.
A getLast function that returns a pointer to the last node in the list.
Create a class diagram for the Node and List class. Then create a header file for these two classes. Include function prologues with appropriate pre- and post-conditions.

File(s) to Submit:

A digital version of your class diagram. Suggested formats are Microsoft Word or PDF.

A .h file containing the class definitions for your List and Node classes. Please put the class definitions for both classes in the same header file.

Grading

Description Points possible Your points
Assignment meets submission guidelines.
o All source code files contain a complete file prologue
o Source code files contain declaration that you did not copy code
o Project has been properly submitted to Canvas
o Code meets style guidelines 2
Your class diagram is in proper UML notation and the classes defined in your .h file meet the specifications of the problem 3