/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package stack1325; /** * * @author jcmt */ public class Stack1325Test { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Stack1325 dumbo = new Stack1325(-40); //negative Stack1325 babar = new Stack1325(); int i; for (i = 0; i < 40; i++) { dumbo.push(i); } dumbo.stkInspector(); for (i = 0; i < 20; i++) //try to overfill babar { if (!babar.push(dumbo.pop())) //dumbo pops even if not pushed { System.out.println("Babar is full. He ate too much hay."); } } System.out.println("Babar has:"); babar.stkInspector(); System.out.println("Dumbo has:"); dumbo.stkInspector(); dumbo.push('p'); System.out.println("Dumbo has:"); dumbo.stkInspector(); if (!dumbo.push(-333)) { System.out.println("Elephants can't manage time negatively."); } System.out.println("Dumbo has:"); dumbo.stkInspector(); if (!dumbo.push(babar)) { System.out.println("Elephants can't manage time negatively."); } System.out.println("Dumbo has:"); dumbo.stkInspector(); } }