FOR C++: Using the material in the textbook (NumberList) as a sample, design you
ID: 3708938 • Letter: F
Question
FOR C++:
Using the material in the textbook (NumberList) as a sample, design your own linked list class to hold a series of capital letters. The class should have the following member functions:
append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges the nodes in the list so that their order is reversed), and search (which returns the position of a specific value in the list. Assume the first node is position 0. If the items is not found, then return a -1 which will tell the calling function that that value does not exist)
High level validation
Character data input from the user should be validated for being a capital letter (A, B, C, ....).
Low level validation
1. Mutator functions which are given a node value that is not a capital letter should have an exit_failure.
2. Mutator functions which are told to access a node that doesn't exist should return a -1 so that the calling function can handle the problem. (No exit_failure used in this case b/c the calling function can't know if the node is there or not.)
Create a menu-driven program to demonstrate your linked list capabilities. Make sure that you have proper constructors and destructors (a destructor must delete every node). Make your input and output professional. Break your code down into functions so as to maintain modular design. No global variables.
Demo your program as follows:
append node
append node
append node
append node
append node
print list
insert at position
print list
delete at position
print list
reverse
print list
search list
DIFFERENT h. FILES FOR EACH CLASS MADE. UPLOAD EACH CLASS CODE AS WELL.
PLEASE SHOW PROGRAM WORKS WITH A PICTURE
SOME HELP:
An example of what the linked list assignment has to do. It uses integers in it's list instead of capital letters, but otherwise it's the same.
https://www.screencast.com/t/w4OeB05A
Contents of NumberList.h
1 // Specification file for the NumberList class
2 #ifndef NUMBERLIST_H
3 #define NUMBERLIST_H
4
5 class NumberList
6 {
7 private:
8 // Declare a structure for the list
9 struct ListNode
10 {
11 double value; // The value in this node
12 struct ListNode *next; // To point to the next node
13 };
14
15 ListNode *head; // List head pointer
16
17 public:
18 // Constructor
19 NumberList()
20 { head = nullptr; }
21
22 // Destructor
23 ~NumberList();
24
25 // Linked list operations
26 void appendNode(double);
27 void insertNode(double);
28 void deleteNode(double);
29 void displayList() const;
30 };
31 #endif
Explanation / Answer
Hi,
Below is the required Program:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.