Question: 1.Create a class, MyDeque , to implement a circular deque. It should include the following methods: insertFront() insertRear() removeFront() removeRear() peekFront() peekRear() isEmpty() isFull() toString()

1.Create a class, MyDeque, to implement a circular deque. It should include the following methods:

insertFront()

insertRear()

removeFront()

removeRear()

peekFront()

peekRear()

isEmpty()

isFull()

toString()

assume that the elements in the deque are stock items. Each item consists of two data:

Item# (String)

Item price (double)

Create a class called Item. Each element in the deque is an object of the Item class. The class should include set/get methods and toString() method.

The deque is a circular queue which needs to handle wrap-around.

You may safely assume that the application program tests the deque for full and empty before insert and remove (It is you to write the application class.)

1.The toString() in MyDeque should always display the data stored in the deque in the sequence from front to rear.

2.Since the deque is a circular queue, You may have to handle wrap-around not only in insert and remove, but also in peek,

1.Write an application class to test all methods defined in MyDeque class. The application should allow the user to provide the length of the deque and operate on the queue as many times as he/she wants till Quit.

The selections in the menu for users are:

1)Insert to front

2)Insert to rear

3)Remove from front

4)Remove from rear

5)Peek front

6)Peek rear

7)Display queue (front -> rear)

8)Quit

1.Write a program to implement a stack class by using the Deque class you implemented. This implementation uses a technique called Delegation. See Note below. It should include the following methods:

push(), pop(), peek(), isEmpty(), isFull() and toString()

The element type is Item.

To avoid the name conflict with the Stack class defined in Java library, please pick any name other than Stack for your class.

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!