Question: Please code this in C++, Please use the driver and cpp file to code this assignment! Please also look at the thing in bold carefully
Please code this in C++, Please use the driver and cpp file to code this assignment!
Please also look at the thing in bold carefully as they are the most important!
----------------------------------------------------------------------------------------------------------
For the assignment, we will design a descending order arranged linked list class. This linked list class should hold a series of char type values. The class should have member functions for appending, inserting, and deleting nodes. Also, it will need a destructor that destroys the list.
For this assignment, you will need to provide these public member functions that perform the following tasks:
A) appendNode appends a node containing the char value passed, to the end of the list.
B) insertNode this function inserts a node with the char parameters value copied to its char member element. This function must insert the values in descending order. Duplicates are okay.
C)deleteNode this function searches for a node with char parameters value as the element to find. The node, if found, is deleted from the list and from memory. If two or more nodes with the same value are found, only one is removed (your choice which one).
The CharList class member-function definitions have been started for you with the displayList function and the destructor already given. Make sure to use the driver program as well. Find both the driver function and member-function definition files that have been provided in the folder under charList_main.cpp and charList.cpp, respectively. Please use the driver and make sure your program can execute the test cases successfully.
DRIVER PROGRAM/MAIN:
#include
int main() {
CharList list;
list.appendNode('t'); list.appendNode('s'); list.appendNode('n'); list.appendNode('m'); list.appendNode('j'); list.appendNode('f'); list.appendNode('c'); list.appendNode('a'); list.insertNode('y'); list.insertNode('0'); list.insertNode('9'); list.insertNode('o'); list.insertNode('p'); list.insertNode('@'); list.insertNode('Q'); list.deleteNode('t'); list.displayList(); return 0; }
charList.cpp:
void CharList::displayList() const
{ ListNode *nodePtr;
nodePtr = head; short count = 0;
while (nodePtr) { std::cout << "[" << nodePtr->value << "] -> "; ++count; nodePtr = nodePtr->next; if (count % 10 == 0) { std::cout << std::endl; count = 0; } } std::cout << std::endl; }
CharList::~CharList() { ListNode *nodePtr; ListNode *nextNode;
nodePtr = head;
while (nodePtr != nullptr) { nextNode = nodePtr->next;
delete nodePtr;
nodePtr = nextNode; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
