public class StackInheritanceTest
1: // Fig. 17.11: StackInheritanceTest.java
2: // Class StackInheritanceTest.
3: import com.deitel.jhtp6.ch17.StackInheritance;
4: import com.deitel.jhtp6.ch17.EmptyListException;
5:
6: public class StackInheritanceTest
7: {
8: public static void main( String args[] )
9: {
10: StackInheritance stack = new StackInheritance();
11:
12: // use push method
13: stack.push( -1 );
14: stack.print();
15: stack.push( 0 );
16: stack.print();
17: stack.push( 1 );
18: stack.print();
19: stack.push( 5 );
20: stack.print();
21:
22: // remove items from stack
23: try
24: {
25: Object removedObject = null;
26:
27: while ( true )
28: {
29: removedObject = stack.pop(); // use pop method
30: System.out.printf( "%s popped\n", removedObject );
31: stack.print();
32: } // end while
33: } // end try
34: catch ( EmptyListException emptyListException )
35: {
36: emptyListException.printStackTrace();
37: } // end catch
38: } // end main
39: } // end class StackInheritanceTest
40:
41:
42: /**************************************************************************
43: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
44: * Pearson Education, Inc. All Rights Reserved. *
45: * *
46: * DISCLAIMER: The authors and publisher of this book have used their *
47: * best efforts in preparing the book. These efforts include the *
48: * development, research, and testing of the theories and programs *
49: * to determine their effectiveness. The authors and publisher make *
50: * no warranty of any kind, expressed or implied, with regard to these *
51: * programs or to the documentation contained in these books. The authors *
52: * and publisher shall not be liable in any event for incidental or *
53: * consequential damages in connection with, or arising out of, the *
54: * furnishing, performance, or use of these programs. *
55: *************************************************************************/