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 firstNode = null; public DoubleLinkedListNode lastNode = null; public DoubleLinkedListNode currentNode = null;

public int nodeNumber = 0; public DoubleLinkedList() { }

// creates first node in list with firstValue public DoubleLinkedList(T firstValue) { firstNode = new DoubleLinkedListNode(firstValue); lastNode = firstNode; currentNode = firstNode; nodeNumber = 1; }

public DoubleLinkedListNode GetCurrentNode() { return currentNode; }

public void InsertFirst(T value) { DoubleLinkedListNode newNode = new DoubleLinkedListNode(value);

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 newNode = new DoubleLinkedListNode(value); newNode.next = firstNode; firstNode.previous = newNode; firstNode = newNode; nodeNumber++; } public void InsertAfterLast(T value) { if (lastNode == null) { InsertFirst(value); return; }

DoubleLinkedListNode newNode = new DoubleLinkedListNode(value); lastNode.next = newNode; newNode.previous = lastNode; lastNode = newNode; currentNode = lastNode; nodeNumber++; } public void InsertAfterCurrent(T value) { if (currentNode == null) { InsertFirst(value); return; }

DoubleLinkedListNode newNode = new DoubleLinkedListNode(value); newNode.next = currentNode.next; newNode.previous = currentNode; if (currentNode.next != null) { currentNode.next.previous = newNode; } currentNode.next = newNode; currentNode = newNode; if (lastNode == currentNode.previous) { lastNode = currentNode; } nodeNumber++; } public int NumberOfNodesInList() { return nodeNumber; } public void DeleteFirst() { if (firstNode == null) { return; }

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 Find(T value) { return FindRecursive(firstNode, value); }

private DoubleLinkedListNode FindRecursive(DoubleLinkedListNode node, T value) { if (node == null) { return null; }

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 node) { if (node == null) { return ""; }

string result = node.value.ToString() + " "; result += GetDisplayStringRecursive(node.next); return result; }

}

internal class DoubleLinkedListNode { public T value; public DoubleLinkedListNode next = null; public DoubleLinkedListNode previous = null;

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

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 Databases Questions!