Question: More practice with Class creation, Pointers, and an introduction to Linked List concepts. MYSting : refers to your string class . DLL : refers to

More practice with Class creation, Pointers, and an introduction to Linked List concepts.
MYSting : refers to your string class .
DLL : refers to the doubly linked list class that you will be writing.
Program Description: Your assignment is to write a linked list class. Your linked list class will store your strings from your MYString class that you wrote for program 3. You will need to change your comparison operators (==,,>) so that they will make a true alphabetical comparison instead of an ASCII comparison.
An alphabetic comparison is what we would normally think of if we were to put words in order. To do this, you can use either one of two c functions tolower(char ch) or toupper(char ch) on the characters as you are comparing them. Both of these functions are found in the cctype library. For better or worse, now The would be equal to the, and so which ever word is inserted into the linked list first would be allowed to enter.
Your linked list will be a doubly linked list, meaning that it will have links to both the next and previous nodes. Your linked list will also be an ordered list, which means that as you insert new strings into the list, they will need to be inserted in the correct position (from smallest to largest). Also, you are only inserting a string into the list if it currently is not in the list, so our list will be made up of unique words.
Programming Suggestion: these are some guidelines on how to start writing your program. Write and test it a little bit at a time.
First add and test the new functions for the MYString class
Write the Node class
Start the DLL class with a constructor and the function (so you can test the contents of your list)
Write and test a simple insert function without worrying about inserting in the right place (for example pushBack which always insert at the back of the list). This function can be used by your copy constructor and = operator
Add a new insert function so that it now inserts in the right place
And so on.....
Node Class:
Member Data:
+ data : MYString
+ next : Node *
+ prev : Node *
Member Functions : return type
Description
Node()
constructor
Node(MYString str)
constructor with initialization data
DoubleLinkedList Class:
Member Data:
- head : Node *
- tail : Node *
- it : mutable Node *{ used as the "iterator" to move through the list by using next(), resetIteration(), and hasMore()}
- count : int
Member Functions : return type
Description
DoubleLinkedList()
default constructor
DoubleLinkedList(const DoubleLinkedList& dll)
copy constructor
= operator( const DoubleLinkedList& dll)
assignment operator
~ DoubleLinkedList()
destructor
operator
output the data to the ostream (separate each string with a blank space)
insert( const MYString& str) : bool
insert the string argument into the list in the proper place (smallest to largest). Do not insert the string if the DLL already has a string of that value. Return true if the string was inserted, otherwise return false
remove( const MYString & str) : bool
if the string argument is found in the DLL remove it from the DLL object. Return true if a string was removed, otherwise return false.
getCount() : int
returns the number of strings that are stored in the DLL.
These following functions are needed for your main to be able to get the MYStrings from the list so that you could remove them from the other list as required. They can make moving though your List very easy....and could be used in the operator, = op, and copy constructor.
Make the it member variable mutable (place key word mutable before the data type in the variable declaration), which means it can change, and not effect the const status of an instance or member function.
Example using the iterator member functions:
// assuming DoubleLinkedList list has been created and filled with data
list.resetIteration(); // puts iterator at head of list
while( list.hasMore()){// is there another word in the list
cout list.next(); // get the word and advance the iterator
}
resetIteration()
Internal to your object, points a member pointer to the first node if there is one, otherwise points to nullptr
next() : MYString
returns the string where your pointer is pointing and then moves it to the next thing (node or nullptr)
hasMore() : bool
returns true if the it member pointer is pointing to a node, otherwise it returns false
MYString Class: Changes
Programming Note: Write and test one or two functions at a time
All of these functions are doing alphabetic comparisons (comparing your strings one char at a time based on their alphabetic value by temporarily getting and comparing their character in lower (or upper) case). "cat" == "Cat" would be true
More practice with Class creation, Pointers, and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!