Hello! I am searching for help with this code. It's for java. I am stuck so help would be greatly appreciated. If you could leave comments in the code so I can get an idea of whats going on would be great. Thank you in advance!
Implement a referenced based Deque. To accomplish this, you will create first create an inner (i.e. inside the Deque class) class Node. The Node class will have the attributes:
You will also create a class Deque<T> that has the following attributes:
Also, it will have the following methods:
A constructor that creates an empty deque.
void addFirst(T item) - adds at the head
T removeFirst() - removes from the head
T getFirst() - returns the element at the head
void addLast(T item) - adds at the tail
T removeLast() - removes from the tail
T getLast() - returns the element at the tail
int size() - returns the number of items in the deque
boolean isEmpty() - true if empty false otherwise
String toString() - returns a String representation of the elements in the deque
void clear() - empties the deque.
You will also create a main method that creates an object of the class Deque. You will:
fill it in with 20 random integers between 0 and 100.
display a menu to the user with the following options:
add at beginning
add at end
remove from beginning
remove from end
Be sure to handle the special cases when the Deque has zero or one nodes!