I need Help Using an "AddSorted" method to a Doubly Linked List
The program reads in a file using the end-line character as a delimiter. The file is assumed to already be sorted. For example:
is read in from alphabet.txt.
You are supposed to have a doubly linked list that adds a node for each line read-in. Then, you have a method, "addSorted," that asks the user if he or she would like to add another node. They type in what they want to add. Ex: "Charlie".
Then the addSorted changes the list and outputs in alphabetical order:
and writes to file accordingly.
I have my code working up until actually having "addSorted" work. I'll post my code here. I'm not going to try to sound like an idiot and speculate as to why my program won't work, because I don't know. I have stated what it's supposed to do and I will post my code. (Do not post condescending remarks, if you are not going to help, don't bother the effort.)
The addSorted Method is in the DList class--thus, it's where the problem is.
- Note: It doesn't have any way to add the node yet. I had "test" outputs in the if-statements, and it does not work properly. It says that "Charlie" should come before term 2 /and/ after term 2. I would like any advice, including any pseudo-code that my code should resemble to ultimately serve the purpose of adding a node in such a way that it remains sorted in the list.
Those should be all you need to get the program working on your own.
I will appreciate any help and advice I can get.