//
//  TestListStack.java
//  
//
//  Created by Herbert J. Bernstein on 2/24/11.
//  Copyright 2011 All rights reserved.
//

import java.io.*;
import java.util.Scanner;

public class TestListStack {
    
    public static void main(String[] args) {
        ListStack a, b, c;
        int ka, kb, kc, i, value;
        a = new ListStack();
        Scanner scanner = new Scanner(System.in);
        
        // Read in Stack a
        
        System.out.print(" number of items stack a: ");
        ka = scanner.nextInt();
        System.out.println(ka);
        for(i = 0; i < ka; i++) {
            System.out.print("a element "+ i + ": ");
            value = scanner.nextInt();
            System.out.println(value);
            a.push(value);
        }
        
        System.out.println("stack a:");
        a.print();
        
        b = new ListStack(a);
        
        System.out.println("stack b:");
        b.print();
        
        //Pop two things from a and print both a and b
        
        value = a.pop();
        System.out.println("Popped from a: "+value);
 
        System.out.println("stack a:");
        a.print();

        System.out.println("stack b:");
        b.print();

        // now do a real copy from a to b, but upside down
        
        b = new ListStack();
        
        while (!a.empty()) {
            b.push(a.pop());
        }

        System.out.println("stack a:");
        a.print();
        
        System.out.println("stack b:");
        b.print();
        
        // but get is back in order by going the other way
        
        while (!b.empty()) {
            a.push(b.pop());
        }
 
        System.out.println("stack a:");
        a.print();
        
        System.out.println("stack b:");
        b.print();
        
        
        return;
    }    

}