Question: ----------------------------tests.java------------------------------- class ObservationDeque { // MAIN. Test the DEQUE on various example arguments. public static void main(String [] args) { Deque deque = new Deque

----------------------------tests.java-------------------------------
class ObservationDeque { // MAIN. Test the DEQUE on various example arguments. public static void main(String [] args) { Deque deque = new Deque(); System.out.println(deque.isEmpty()); // true 2 points. try { System.out.println(deque.dequeueFront()); } catch (IllegalStateException ignore) { System.out.println("No dequeueFront."); // No dequeueFront. 2 points. } try { System.out.println(deque.dequeueRear()); } catch (IllegalStateException ignore) { System.out.println("No dequeueRear."); // No dequeueRear. 2 points. } // Enqueueing to the rear and dequeueing from the rear makes the DEQUE act // like a stack. deque.enqueueRear("A"); deque.enqueueRear("B"); deque.enqueueRear("C"); System.out.println(deque.isEmpty()); // false 2 points. System.out.println(deque.dequeueRear()); // C 2 points. System.out.println(deque.dequeueRear()); // B 2 points. System.out.println(deque.dequeueRear()); // A 2 points. System.out.println(deque.isEmpty()); // true 2 points. // Enqueueing to the rear and dequeueing from the front makes the DEQUE act // like a queue. deque.enqueueRear("A"); deque.enqueueRear("B"); deque.enqueueRear("C"); System.out.println(deque.dequeueFront()); // A 2 points. System.out.println(deque.dequeueFront()); // B 2 points. System.out.println(deque.dequeueFront()); // C 2 points. System.out.println(deque.isEmpty()); // true 2 points. // Enqueueing to the front and dequeueing from the front makes the DEQUE act // like a stack. deque.enqueueFront("A"); deque.enqueueFront("B"); deque.enqueueFront("C"); System.out.println(deque.dequeueFront()); // C 2 points. System.out.println(deque.dequeueFront()); // B 2 points. System.out.println(deque.dequeueFront()); // A 2 points. System.out.println(deque.isEmpty()); // true 2 points. // Enqueueing to the front and dequeueing from the rear makes the DEQUE act // like a queue. deque.enqueueFront("A"); deque.enqueueFront("B"); deque.enqueueFront("C"); System.out.println(deque.dequeueRear()); // A 2 points. System.out.println(deque.dequeueRear()); // B 2 points. System.out.println(deque.dequeueRear()); // C 2 points. System.out.println(deque.isEmpty()); // true 2 points. } } 0. Introduction. A deque (pronounced like deck) is a double-ended queue. Deques are like ordinary queues, except that objects can be inserted and deleted at both the front and the rear. Unlike the queues described in the lectures, they work without special cases. In this laboratory assignment, you will write a Java class called Deque that implements a deque 1. Theory. A deque can be implemented easily using a circular, doubly-linked list with a head node. For example, a deque containing the objects A, B, C, D, and E might use a list that looks like the following diagram. (To save space, the diagram does not show arrows pointing to those objects head The variable head points to the head node. The expression head.right points to the node at the front of the deque, which in turn points to the object A. The expression head.left points to the node at the rear of the deque, which in turn points to the object E. 2. Implementation. You must write a class called Deque that implements a deque, using a doubly-linked circular list with a head node. Instances of Deque must be able to hold objects whose type is given by a class parameter Base. As a result, your class Deque must look like this, with your code in place of the three dots
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
