public class QueueTest
1: // Fig. 17.14: QueueTest.java
2: // Class QueueTest.
3: import com.deitel.jhtp6.ch17.Queue;
4: import com.deitel.jhtp6.ch17.EmptyListException;
5:
6: public class QueueTest
7: {
8: public static void main( String args[] )
9: {
10: Queue queue = new Queue();
11:
12: // use enqueue method
13: queue.enqueue( -1 );
14: queue.print();
15: queue.enqueue( 0 );
16: queue.print();
17: queue.enqueue( 1 );
18: queue.print();
19: queue.enqueue( 5 );
20: queue.print();
21:
22: // remove objects from queue
23: try
24: {
25: Object removedObject = null;
26:
27: while ( true )
28: {
29: removedObject = queue.dequeue(); // use dequeue method
30: System.out.printf( "%s dequeued\n", removedObject );
31: queue.print();
32: } // end while
33: } // end try
34: catch ( EmptyListException emptyListException )
35: {
36: emptyListException.printStackTrace();
37: } // end catch
38: } // end main
39: } // end class QueueTest
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: *************************************************************************/