Question: CODE IN JAVA Queue.java public interface Queue { /** * Returns the number of elements in the queue. * @return number of elements in the

CODE IN JAVA

CODE IN JAVA Queue.java public interface Queue { /** * Returns the

Queue.java

public interface Queue {

/**

* Returns the number of elements in the queue.

* @return number of elements in the queue

*/

int size();

/**

* Tests whether the queue is empty.

* @return true if the queue is empty, false otherwise

*/

boolean isEmpty();

/**

* Inserts an element at the rear of the queue.

* @param e the element to be inserted

*/

void enqueue(E e);

/**

* Returns, but does not remove, the first element of the queue.

* @return the first element of the queue (or null if empty)

*/

E first();

/**

* Removes and returns the first element of the queue.

* @return element removed (or null if empty)

*/

E dequeue();

}

LinkedList from Java Class Library: LinkedList (Java SE 16 & JDK 16)

https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/LinkedList.html

2. Create a class named LinkedJavaQueue that implements our Queue interface that is provided. Use the adapter design pattern with the built-in Linkedlist from Java Class Library: LinkedList (Java SE 16 & JDK 16) a. Override the toString() method to return the Linkedlist's string representation. b. Work with the Queue to simulate the waitlist of a call center. Declare a LinkedJavaQueue of String instances and demonstrate the queue methods in the following manner: - Add Alice, Anna, Ness, Joy to the queue. Display the current queue. Add Brendan and Rosa to the queue. Display the current queue. Remove an element from the queue. Display the current queue. Check what the next element is in the queue. Add Ryan to the queue. Display the current queue. Remove two customers from the queue Display the current size of the queue. Sample output: Currently waiting: [Alice, Anna, Ness, Joy] Currently waiting: [Alice, Anna, Ness, Joy, Brendan, Rosa] An agent will now answer Alice Currently waiting: [Anna, Ness, Joy, Brendan, Rosa] The next customer to be answered is Anna Currently waiting: [Anna, Ness, Joy, Brendan, Rosa, Ryan] An agent will now answer Anna An agent will now answer Ness Number of customers waiting: 4

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!