Incomplete input:
| /**
| * Queue Manager
| * 1. "has a" Queue
| * 2. support management of Queue tasks (aka: titling, adding a list, printing)
| */
| class QueueManager<T> {
| // queue data
| private final String name; // name of queue
| private int count = 0; // number of objects in queue
| public final Queue<T> queue = new Queue<>(); // queue object
|
| /**
| * Queue constructor
| * Title with empty queue
| */
| public QueueManager(String name) {
| this.name = name;
| }
|
| /**
| * Queue constructor
| * Title with series of Arrays of Objects
| */
| public QueueManager(String name, T[]... seriesOfObjects) {
| this.name = name;
| this.addList(seriesOfObjects);
| }
|
| /**
| * Add a list of objects to queue
| */
| public void addList(T[]... seriesOfObjects) { //accepts multiple generic T lists
| for (T[] objects: seriesOfObjects)
| for (T data : objects) {
| this.queue.add(data);
| this.count++;
| }
| }
|
| public class QueueToStackExample {
| public static void main(String[] args) {
| Object[] numbers = new Integer[] { 1, 2, 3, 4, 5};
| QueueChange qNumbers = new QueueChange("Numbers");
|
| for (Object o : numbers) {
| qNumbers.add(o);
| }
|
| Stack<Object> stack = new Stack<>();
|
| System.out.println("Stack Initial: " + stack);
| System.out.print("Queue Initial: ");
| qNumbers.printIntQueue();
|
| // Add integers 1 through 5 to the stack
|
| int count = qNumbers.getCount();
| for (int i = 0; i < count; i++) {
| stack.push(qNumbers.delete());
| }
|
| System.out.println("Stack Full: " + stack);
| System.out.print("Queue when Stacked: ");
| qNumbers.printIntQueue();
|
| for (int i = 0; i < count; i++) {
| qNumbers.add(stack.pop());
| }
|
| System.out.println("Stack Final: " + stack);
| System.out.print("Queue Final: ");
| qNumbers.printIntQueue();
| }
| }
| QueueToStackExample.main(null);