X1019: Use a Stack to a Reverse order of a Queue

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 that reverses the elements in a queue. For example, if the queue starts with "A","B","C" then after the routine runs, the queue should have "C","B", "A". This should work for all values in the queue. One easy way to do this is to use a stack and copy all elements from the queue and then copy the contents of the stack back to the queue. You should use a StackArray<String>. If queue is null, then do nothing. Make sure you use the interfaces from above.

Your Answer:

Feedback

Your feedback will appear here when you check your answer.