Question: Using visual studio 2022, a C# windows form application, and your DoubleLinkedClass and DoubleLinkedNode classes from project 5, implement a DequeueClass, a StackClass, and a
Using visual studio 2022, a C# windows form application, and your DoubleLinkedClass and DoubleLinkedNode classes from project 5, implement a DequeueClass, a StackClass, and a QueueClass. Do not use any arrays, lists, dictionaries, or other built in data structures, only instances of your linkedLists classes from project 5. The dequeue class needs to contain a reference to an instance of your DoubleLinkedList class, with the QueueClass and StackClass inheriting from the Dequeue class. Your Stack and Queue pop and push need to be one-line calls to the Dequeue popLeft, pushLeft, popRight, pushRight. Do not copy the code from the dequeue class to implement the Stack and Queue.
DoubleLinkedClasses From2263Project5
internal class DoubleLinkedList
public DoubleLinkedListNode
public int nodeNumber = 0; public DoubleLinkedList() { }
// creates first node in list with firstValue public DoubleLinkedList(T firstValue) { firstNode = new DoubleLinkedListNode
public DoubleLinkedListNode
public void InsertFirst(T value) { DoubleLinkedListNode
if (firstNode == null) { firstNode = newNode; lastNode = firstNode; currentNode = firstNode; } else {
newNode.next = firstNode; firstNode.previous = newNode; firstNode = newNode; currentNode = firstNode; }
nodeNumber++; } public void InsertBeforeFirst(T value) { if (firstNode == null) { InsertFirst(value); return; }
DoubleLinkedListNode
DoubleLinkedListNode
DoubleLinkedListNode
if (firstNode.next == null) { firstNode = null; lastNode = null; currentNode = null; } else { firstNode = firstNode.next; firstNode.previous = null; currentNode = firstNode; } nodeNumber--; } public void DeleteLast() { if (lastNode == null) { return; }
if (lastNode.previous == null) { firstNode = null; lastNode = null; currentNode = null; } else { lastNode = lastNode.previous; lastNode.next = null; currentNode = lastNode; } nodeNumber--; } public void DeleteCurrent() { if (currentNode == null) { return; }
if (currentNode.previous == null) { DeleteFirst(); return; }
if (currentNode.next == null) { DeleteLast(); return; }
currentNode.previous.next = currentNode.next; currentNode.next.previous = currentNode.previous; currentNode = currentNode.next; nodeNumber--; } public void MoveToNext() { if (currentNode == null || currentNode.next == null) { return; }
currentNode = currentNode.next; }
public void MoveToPrevious() { if (currentNode == null || currentNode.previous == null) { return; }
currentNode = currentNode.previous; }
public DoubleLinkedListNode
private DoubleLinkedListNode
if (node.value.Equals(value)) { return node; }
return FindRecursive(node.next, value); }
public string GetDisplayString() { if (firstNode == null) { return ""; }
return GetDisplayStringRecursive(firstNode); }
private string GetDisplayStringRecursive(DoubleLinkedListNode
string result = node.value.ToString() + " "; result += GetDisplayStringRecursive(node.next); return result; }
}
internal class DoubleLinkedListNode
public DoubleLinkedListNode(T value) { this.value = value; previous = null; next = null; }
private DoubleLinkedListNode() { value = default(T); } }
Develop a test harness, that allows testing rapid, but effective testing of your classes, including inserting and deleting 6 or more integers, including completely filling, completely emptying, and then refilling your data structures
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
