Project 2 - Basic Doubly-Linked List

Objectives

Description

For this project, you get to provide the list implementation that goes with the command-line interface from Project 1.

Requirements

You are required to use the List interface from the textbook. Additionally, you are required to use the Link class for doubly-linked nodes (which is different than the Link class for the practice assignments). Furthermore, you are required to start with the textbook's implementation of a doubly-linked list, but are not allowed to use a header node nor a trailer node. Use the BasicDLList class, which still has the required head and tail instance variables, but has removed the allocation of the header and trailer nodes. Do not allocate memory for an empty header nor a trailer node. In its current form, executing methods in the BasicDLList class will currently cause several run-time errors. An example of this is that for this project, the definition of curr being at the end of the list, is that it is null. For example, you need to update the moveToEnd method to be:

public void moveToEnd() {
    curr = null; // Set curr at list end
}
Your task is to modify your BasicDLList class so that the results of each method are identical with those of the DLList class. Expand your MenuDriver class from Project 1 by adding in code to create a BasicDLList object and calls its methods. The example below details the required text to be displayed.

Example

Note, user input is in bold face blue and underlined text is required for test cases.
Welcome to the Menu Driver for a bare bones list!

Command options:
I string_to_insert  (insert a string at the current position)
A string_to_append  (append a string at the end)
R  (remove the string at the current position)
S  (move the current position to the start)
E  (move the current position to the end)
P  (move the current position backward)
F  (move the current position forward)
L  (display the length of the list)
C  (display the current position number)
M number  (move the current position to specific position)
D  (display the string at the current position)
V  (display all strings)
O  (display these options)
Q  (quit)

Please enter a command (or 'O' for all of the options): I Inserting this text ;)
Inserting 'Inserting this text ;)' ...

Please enter a command (or 'O' for all of the options): A Appending this text :)
Appending 'Appending this text :)' ...

Please enter a command (or 'O' for all of the options): V| Inserting this text ;), Appending this text :) ⟩

Please enter a command (or 'O' for all of the options): E
Moving the current position to the end ...

Please enter a command (or 'O' for all of the options): C
Displaying the current position number ...
The current position is 2

Please enter a command (or 'O' for all of the options): P
Moving the current position backward ...

Please enter a command (or 'O' for all of the options): C
Displaying the current position number ...
The current position is 1

Please enter a command (or 'O' for all of the options): F
Moving the current position forward ...

Please enter a command (or 'O' for all of the options): C
Displaying the current position number ...
The current position is 2

Please enter a command (or 'O' for all of the options): L
Displaying the length of the list ...
Length is 2

Please enter a command (or 'O' for all of the options): M 7
Moving current position to 7 ...
Failed to move position to 7!

Please enter a command (or 'O' for all of the options): M 0
Moving current position to 0 ...
Successfully moved position to 0

Please enter a command (or 'O' for all of the options): R
Removing the string at the current position ...
Removed 'Inserting this text ;)'

Please enter a command (or 'O' for all of the options): V| Appending this text :) ⟩

Please enter a command (or 'O' for all of the options): S
Moving the current position to the start ...

Please enter a command (or 'O' for all of the options): D
Displaying the string at the current position  ...
The current value is 'Appending this text :)'

Please enter a command (or 'O' for all of the options): O
Command options:
I string_to_insert  (insert a string at the current position)
A string_to_append  (append a string at the end)
R  (remove the string at the current position)
S  (move the current position to the start)
E  (move the current position to the end)
P  (move the current position backward)
F  (move the current position forward)
L  (display the length of the list)
C  (display the current position number)
M number  (move the current position to specific position)
D  (display the string at the current position)
V  (display all strings)
O  (display these options)
Q  (quit)

Please enter a command (or 'O' for all of the options): Q


Good-bye

Rubric:

Points      Item
----------  --------------------------------------------------------------
_____ / 10  Style
            + Code is indented correctly
            + Documentation: (written for another software developer)
              * All source code files include Javadoc header block with description, @author, @version, etc.
              * Javadoc (with block tags, for example @param, @return) before each method
              * All non-trivial variables are commented
              * Comments included before major portions of code
_____ /     Compiles (max of 50% if it does not compile)
_____ / 88  Successfully passes codePost tests
_____ /  2  Completed rubric (estimates for each line including hours spent)

_____ /100  Total


_____  Approximate number of hours spent

I, (REPLACE WITH YOUR FULL NAME), affirm that the code that I submitted is my own work and that I did not receive help that was not authorized by the instructor.

Copy and paste this rubric into a rubric-basicDLList.txt file (not a .docx, .doc nor .rtf file). Think of this as a checklist to ensure that you receive the maximum points possible. For each grade item, fill in your estimate for the grade you deserve. Additionally, include your estimate of how many hours your spent. Lastly, replace, "(REPLACE WITH YOUR FULL NAME)" with your full name to indicate that what you are submitting is entirely your own work.

Submission

Submit your MenuDriver.java and BasicDLList.java files to codePost.io. Do not submit List.java nor Link.java (they are already loaded in codePost). To register for a free codePost account, please follow these instructions.
Submit your rubric-basicDLList.txt file to the appropriate Assignment folder in CougarVIEW. If you resubmit it, the new file will replace the older one.

Notes

Let me recommend that you take the following steps when your planning your implementation, writing the code and debugging:
  1. Solve a scenario manually.
    For example, if you're trying to insert into an empty list, draw what the list looks like before and after inserting the node. If you're working on removing the last node in a list, then draw the list after inserting / appending an item and again after the removal. Be meticulous about the values for head, tail, curr and listSize. Trust me, this will save you time when you're really stuck or if you do it in the planning stage, to help you avoid being stuck.
  2. Identify the earliest point that your results diverge from what you expected (from Step 1).
    One way to accomplish this is to temporarily display the values of head, tail, curr and listSize and the contents of the list after every command. Part of this can be accomplished with the same code used to execute the “V” command. Then, check that output against your results from Step 1. Focus on the earliest point where your plan and execution diff before tackling later issues.
  3. Use a debugger and/or visualization tool.
    Use one or both of these tools to step through the scenario and verify that every value of head, tail, curr and listSize match what you had in Step 1 after every operation. Let me recommend that you decide what the debugger should do (for example, execute the body of an if statement or not) and then execute one line of code. Repeat until it diverges from what you thought (or your results in Step 1).
If you've spent more than an hour applying these steps to a specific challenge, then please visit with the CSU CS (or ACT) tutors. Additionally, you can send me an email describing the steps you've taken (and what is right and what is different than what you expected).