Question: Java code please, you need to write four class, StackInterface.java - generic interface for stacks. ListStack.java - generic implementation of a stack backed by a
Java code please, you need to write four class, StackInterface.java - generic interface for stacks. ListStack.java - generic implementation of a stack backed by a linked list. QueueInterface.java - generic interface for queues. ListQueue.java - generic implementation of a queue back by a linked list. I will give you thumb up 


For PA7, you will take your implementations of a Stack backed by a linked List (ListStack.java) and a queue backed by a linked List (ListQueue.java) and make these implementations generic. This may require adding zero additional lines of code to these files! Wow! You will also adapt the StackInterface.java and QueueInterface.java files that we provided in the starter code. First update StackInterface.java. The version we gave you for PA6 has been provided in the starter code for PAZ as well. This interface is specific to stacks of integers. Make it generic! Update QueueInterface.java. The version we gave you for PA6 has been provided in the starter code for PAZ as well. This interface is specific to queues of integers. Make it generic! Update your implementation of ListStack to be generic. Update your implementation of ListQueue to be generic. Also, do not forget to override equals, toString, and write a copy constructor just as you did for the last assignment. You will also need a constructor with zero arguments. A small note: when writing the equals methods for these classes, you might encounter a warning like: "Type safety: Unchecked cast from Object to ListStack". Do not worry about it. There is only so much we can cover in this class, we will let this one slide by. ** cases. 12 13 17 * */ *Stackinterface.java X * This interface is specific to stacks of integers.Make it generic! 3 * Note that the below comments were copied over from our non-generic 4 * version of this interface. One of the changes you need to make to 5 * the comments is that they say to return -1 for some error handling 6 Since you are now returning an object, and not an integer, you 7 now need to return null. This is addressed in the PA spes as well. 8 */ 9 interface StackInterface { 100 /* 11 * Add an element to the top of the stack. */ void push(int value); 140 15 * Remove and return the top element in the stack. 16 * If the user attempts to pop an empty stack, ignore the 18 request (i.e. make no changes to the stack) and return -1. 19 int pop(); 216 /* 22 * Return (but do NOT remove) the top element of the stack. 23 24 * If the user attempts to peek on an empty stack, ignore the 25 request (i.e. make no changes to the stack) and return -1. 26 */ 27 int peek(); 280 /* 29 * Returns true if the stack has no elements. 30 31 boolean isEmpty(); 320 33 * Returns the number of elements in the stack. 34 */ int size(); 360 /* 37 * Removes all elements from the stack. 38 */ 39 void clear(); 20 * 35 ** cases. D *Queueinterface.java X * This interface is specific to queues of integers.Make it generic! 3 * Note that the below comments were copied over from our non-generic 4 * version of this interface. One of the changes you need to make to 5 * the comments is that they say to return -1 for some error handling 6 Since you are now returning an object, and not an integer, you 7 now need to return null. This is addressed in the PA spes as well. 8 */ 9 interface Queue Interface { 100 /* 11 * Add an element to the back of the queue. 12 */ 13 void enqueue(int value); 140 /* 15 * Remove and return the front element in the queue. 16 * If the user attempts to dequeue from an empty queue, ignore the 17 request (i.e. make no changes to your queue) and return -1. 18 */ 19 int dequeue(); 200 21 * Return (but do NOT remove) the front element of the queue. 22 23 * If the user tries to peek on an empty queue, ignore the 24 * request (i.e. make no changes to your queue) and return -1. 25 */ 26 int peek(); 270 /* 28 * Returns true if the queue has no elements. 29 */ 30 boolean isEmpty(); 310 32 * Returns the number of elements in the queue. 33 */ int size(); 350 /* 36 * Removes all elements from the queue. 37 */ void clear(); 34 38 20 2 For PA7, you will take your implementations of a Stack backed by a linked List (ListStack.java) and a queue backed by a linked List (ListQueue.java) and make these implementations generic. This may require adding zero additional lines of code to these files! Wow! You will also adapt the StackInterface.java and QueueInterface.java files that we provided in the starter code. First update StackInterface.java. The version we gave you for PA6 has been provided in the starter code for PAZ as well. This interface is specific to stacks of integers. Make it generic! Update QueueInterface.java. The version we gave you for PA6 has been provided in the starter code for PAZ as well. This interface is specific to queues of integers. Make it generic! Update your implementation of ListStack to be generic. Update your implementation of ListQueue to be generic. Also, do not forget to override equals, toString, and write a copy constructor just as you did for the last assignment. You will also need a constructor with zero arguments. A small note: when writing the equals methods for these classes, you might encounter a warning like: "Type safety: Unchecked cast from Object to ListStack". Do not worry about it. There is only so much we can cover in this class, we will let this one slide by. ** cases. 12 13 17 * */ *Stackinterface.java X * This interface is specific to stacks of integers.Make it generic! 3 * Note that the below comments were copied over from our non-generic 4 * version of this interface. One of the changes you need to make to 5 * the comments is that they say to return -1 for some error handling 6 Since you are now returning an object, and not an integer, you 7 now need to return null. This is addressed in the PA spes as well. 8 */ 9 interface StackInterface { 100 /* 11 * Add an element to the top of the stack. */ void push(int value); 140 15 * Remove and return the top element in the stack. 16 * If the user attempts to pop an empty stack, ignore the 18 request (i.e. make no changes to the stack) and return -1. 19 int pop(); 216 /* 22 * Return (but do NOT remove) the top element of the stack. 23 24 * If the user attempts to peek on an empty stack, ignore the 25 request (i.e. make no changes to the stack) and return -1. 26 */ 27 int peek(); 280 /* 29 * Returns true if the stack has no elements. 30 31 boolean isEmpty(); 320 33 * Returns the number of elements in the stack. 34 */ int size(); 360 /* 37 * Removes all elements from the stack. 38 */ 39 void clear(); 20 * 35 ** cases. D *Queueinterface.java X * This interface is specific to queues of integers.Make it generic! 3 * Note that the below comments were copied over from our non-generic 4 * version of this interface. One of the changes you need to make to 5 * the comments is that they say to return -1 for some error handling 6 Since you are now returning an object, and not an integer, you 7 now need to return null. This is addressed in the PA spes as well. 8 */ 9 interface Queue Interface { 100 /* 11 * Add an element to the back of the queue. 12 */ 13 void enqueue(int value); 140 /* 15 * Remove and return the front element in the queue. 16 * If the user attempts to dequeue from an empty queue, ignore the 17 request (i.e. make no changes to your queue) and return -1. 18 */ 19 int dequeue(); 200 21 * Return (but do NOT remove) the front element of the queue. 22 23 * If the user tries to peek on an empty queue, ignore the 24 * request (i.e. make no changes to your queue) and return -1. 25 */ 26 int peek(); 270 /* 28 * Returns true if the queue has no elements. 29 */ 30 boolean isEmpty(); 310 32 * Returns the number of elements in the queue. 33 */ int size(); 350 /* 36 * Removes all elements from the queue. 37 */ void clear(); 34 38 20 2