Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m not sure if i\'m doing this right and don\'t know what values do these meth

ID: 3639883 • Letter: I

Question

I'm not sure if i'm doing this right and don't know what values do these methods return so I have placed null there for now so I won't have any errors. I also don't have the enqueue method filled out cause i was unsure what should go there. Please help me fill out the returns and the enqueue method.

public class ObjectQueue extends LinkedList implements Queue
{
private int size;

public int size()
{
return size;
}

public boolean isEmpty()
{
return false;
}

public Object front() throws EmptyQueueException
{
if(isEmpty())
{
throw new EmptyQueueException("Queue is empty!");
}
return null;
}

public Object dequeue() throws EmptyQueueException
{
if(isEmpty())
{
throw new EmptyQueueException("Queue is empty!");
}
return null;
}

public void enqueue(Object item)
{

}


}

Explanation / Answer

PS: Please rate the answer You are having couple of errors. If you try to use this queue in multi-threaded program, you will have race conditions. Here is a correct implementation which works for single threaded and multi threaded. If you dont want multithreaded, just use the enqueue and dequeue functions without using synchronized keyword. import java.util.*; public class ObjectQueue implements Queue { Object data; LinkedList queues[]; int mx; int nq; public synchronized void setData(Object o) { data = o; } public synchronized Object getData() { return data; } public ObjectQueue(int _nq, int _mx) { nq = _nq; mx = _mx; queues = new LinkedList[nq]; for (int n = 0; n