Question: Can someone code this in Java and make sure it follows the same menu as posted in the second picture and does everything in the

 Can someone code this in Java and make sure it followsthe same menu as posted in the second picture and does everythingin the rubric posted. public interface QueueInterface { public void enqueue(T newEntry);

Can someone code this in Java and make sure it follows the same menu as posted in the second picture and does everything in the rubric posted.

public interface QueueInterface { public void enqueue(T newEntry); /** Removes and returns the entry at the front of this queue. @return either the object at the front of the queue or, if the queue is empty before the operation, null */ public T dequeue();

public boolean removeAll(); /** Retrieves the entry at the front of this queue. @return either the object at the front of the queue or, if the queue is empty, null */ public T getFront(); /** Detects whether this queue is empty. @return true if the queue is empty, or false otherwise */ public boolean isEmpty(); /** Removes all entries from this queue. */ public void clear();

}

public class LinkedNodesQueue implements QueueInterface {

private Node firstNode; // references node at front of queue private Node lastNode; // references node at back of queue

public LinkedNodesQueue() { firstNode = null; lastNode = null; }

@Override public void enqueue(T newEntry) { Node newNode = new Node(newEntry, null); if (isEmpty()) { firstNode = newNode; } else { lastNode.setNext(newNode); } lastNode = newNode; }

@Override public T dequeue() { T front = null; if (!isEmpty()) { front = firstNode.getItem(); firstNode = firstNode.getNext(); if (firstNode == null) { lastNode = null; } } // end if return front; }

@Override public T getFront() { T front = null; if (!isEmpty()) { front = firstNode.getItem(); } return front; }

@Override public boolean isEmpty() { return (firstNode == null) && (lastNode == null); }

@Override public void clear() { firstNode = null; lastNode = null; }

class Node {

public T getItem() { return item; }

public void setItem(T item) { this.item = item; }

public Node getNext() { return next; }

public void setNext(Node next) { this.next = next; }

T item; Node next;

Node(T item) { this(item, null); }

Node(T item, Node next) { this.item = item; this.next = next; }

@Override public String toString() { return item.toString(); }

} }

Homework 05 A double linked queue is similar to the linked queue we learned in the class, except that each node has previous and next pointers. See the following figure: lastNode firstNode NULL NULL As you can see, instead of only next link there is also a previous link that links the node to the previous node in the queue. First node: the previous of this node is NULL Last node: the next of this node is NULL In this assignment you will implement this queue with all its standard operations. Make sure your implementation maintains the FIFO characteristic. Implementation 1. Queuelntreface: This is the same Queue interface that we used in implementing array and node based queues. 2. DoubleLinkedQueue: This where your implementation of all the standard operations of the queue (enqueue, dequeue, ..etc) 3. Node: In this class you will change the class and add the data member previous. 4. DoubleLinkedQueueTest: This is the test class. Define the main function with the standard menu. Homework 05 A double linked queue is similar to the linked queue we learned in the class, except that each node has previous and next pointers. See the following figure: lastNode firstNode NULL NULL As you can see, instead of only next link there is also a previous link that links the node to the previous node in the queue. First node: the previous of this node is NULL Last node: the next of this node is NULL In this assignment you will implement this queue with all its standard operations. Make sure your implementation maintains the FIFO characteristic. Implementation 1. Queuelntreface: This is the same Queue interface that we used in implementing array and node based queues. 2. DoubleLinkedQueue: This where your implementation of all the standard operations of the queue (enqueue, dequeue, ..etc) 3. Node: In this class you will change the class and add the data member previous. 4. DoubleLinkedQueueTest: This is the test class. Define the main function with the standard menu

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!