Skip to main content
deleted 6 characters in body
Source Link
jermiah
  • 115
  • 1
  • 10
import java.util.*;


public class StackQueue {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1StackQueue queue = new StackQueueHw1StackQueue();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueue {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueue {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueue queue = new StackQueue();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
deleted 3 characters in body
Source Link
jermiah
  • 115
  • 1
  • 10
import java.util.*;


public class StackQueueHw1StackQueue {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueueHw1 {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueue {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueueHw1 {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); //more removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueueHw1 {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); //more
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
import java.util.*;


public class StackQueueHw1 {

    Stack stack1 = new Stack();
    Stack stack2 = new Stack();
    Stack temp   = new Stack();


    public void enqueue(String element) {
        stack1.push(element);
        System.out.println(stack1.toString() + "Stack1");
    }


        public void dequeue(){
            System.out.println(stack1.toString() + "\n\nStack1");

            if(!stack1.empty() & stack1.size()> 1 & !stack2.empty()) {           // if there are elements in both stacks
                System.out.println("IM IN THE BLOCK");
                while (!stack2.empty()) {
                    temp.push(stack2.pop());
                    System.out.println(temp.toString() + " TEMPP----");
                    System.out.println(stack2.toString() + " STACK 2---");
                }
                while (!temp.empty()) {
                    stack1.push(temp.pop());
                    System.out.println(stack1.toString() + " STACK1 ----");
                }
                System.out.println(stack1.pop() + " Has been removed");
                System.out.println(stack1.toString() + "STACK 1----");
                System.out.println(stack2.toString()+ "STACK 2----");

                if(stack2.empty()){
                    while (!stack1.empty()) {
                        temp.push(stack1.pop());
                        System.out.println(temp.toString() + " temp ----");
                    }
                    System.out.println(stack1.addAll(temp));
                    System.out.println(stack1.toString()+ "STACK ! ADD");
                    temp.removeAllElements();
                    System.out.println(temp.toString() + "TEMP _++++_+_+_+_");
                }
                }



           else if(stack1.empty()){

                System.out.println("\n\nstack1 is empty ");
                System.out.println(stack2.pop() + " Has been removed");
            }else {
                System.out.println("\n\n");
                while (!stack1.empty()) {
                    System.out.println(stack2.toString() + "Stack2 - second part");
                    stack2.push(stack1.pop());

                }
            System.out.println(stack1.toString()+ "stack1");
            System.out.println(stack2.toString()+"stack2");
            System.out.println(stack2.pop() + " Has been removed");
                    }

        }
    }






public class Main {
    public static void main(String[] args){
        StackQueueHw1 queue = new StackQueueHw1();

        queue.enqueue("hey");
        queue.enqueue("I");
        queue.enqueue("am");
        queue.enqueue("Jeremiah");
        queue.enqueue("now");
        queue.dequeue(); //removes hey
        queue.dequeue(); //removes i
        queue.dequeue();// removes am
        queue.enqueue("one ");
        queue.enqueue("more");
        queue.enqueue("time");
        queue.dequeue();  // removes jeremiah

        // i had to reverse the stack1 order here 
        queue.dequeue(); // removes now
        //queue.dequeue(); // removes one
        queue.enqueue("FIRST");
        queue.dequeue();//removes FIRST


        System.out.println(queue.stack1.toString()  + " END S1");
        System.out.println( queue.stack2.toString() + " END S2");
        System.out.println(queue.temp.toString() + " END temp");


    }

}
Source Link
jermiah
  • 115
  • 1
  • 10
Loading