X1017: Copy Queue to a Stack

Use these two interfaces to solve this problem.

public interface QueueADT<E> {
  public void clear();
  public boolean enqueue(E it);
  public E dequeue();
  public E frontValue();
  public int numElements();
  public boolean isEmpty();
}

interface StackADT<E> {
  public void clear();
  public boolean push(E it);
  public E pop();
  public E topValue();
  public int numElements();
  public boolean isEmpty();
}

Write a method to remove all of the elements from the 'queue' (one by one) and add them to a newly created stack (use a StackArray<String>) and push the values in the stack. Return this stack. If queue is null, then just return an empty stack. Make sure you use the interfaces from above.

Your Answer:

Feedback

Your feedback will appear here when you check your answer.