We recently discussed deques, which are Double-Sided Queues. For this part, you will implement a deque. You will call this class Deque, which will be stored in a Deque.java file.
The requirements for the deque are as follows.
Your deque should accept integers.
You should be able to:
The following restrictions should also be followed:
Your Main.java file will contain a single main function. Your program should loop indefinitely unless the user enters the word "exit".
In your loop, give the user the option to choose an action for how they'll interact with the deque. Options include:
If the user asks to add a value to the queue, give them the option to choose an integer to add. When they press enter, the value they entered should be added to the deque. You should then print out the contents of the deque.
If the user asks to remove a value, the appropriate value should be removed.
If the user asks to peek at the front or rear, the appropriate value should be printed to the screen. The loop should repeat until "exit" is typed in. (Or you can give the user a yes/no option to continue. In essence, the user should be able to type something in to exit the loop.)
Type in deque option (options: addFront, addRear, removeFront, removeRear, peekFront, peekRear): addRear
Enter a value to store in deque (type 'exit' to quit): 5
Deque: [5]
Type in deque option (options: addFront, addRear, removeFront, removeRear, peekFront, peekRear): addRear
Enter a value to store in deque (type 'exit' to quit): 10
Deque: [5, 10]
Type in deque option (options: addFront, addRear, removeFront, removeRear, peekFront, peekRear): addFront
Enter a value to store in deque (type 'exit' to quit): 152
Deque: [152, 5, 10]
Type in deque option (options: addFront, addRear, removeFront, removeRear, peekFront, peekRear): peekFront
Front value: 152
Deque: [152, 5, 10]
Type in deque option (options: addFront, addRear, removeFront, removeRear, peekFront, peekRear): removeRear
Deque: [152, 5]