Created
June 5, 2014 04:05
-
-
Save cdduarte/71b30527beefb2082d85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Driver - for Queue<E> generic class. | |
* | |
* @author christopher duarte | |
* @author robert irwin | |
* @course cis551 | |
* @assignment homework5 | |
* @param <E> | |
*/ | |
public class Driver { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) | |
{ | |
Queue<Integer> q = new Queue<Integer>(100); | |
System.out.printf( "Queue q is %s%n", q.isEmpty() ? "empty" : "not empty" ); | |
q.add(5); | |
System.out.printf( "Queue q added element: %d%n", 5 ); | |
System.out.printf( "Queue q first element: %d%n", q.element() ); | |
q.add(10); | |
System.out.printf( "Queue q added element: %d%n", 10 ); | |
System.out.printf( "Queue q first element: %d%n", q.element() ); | |
q.add(15); | |
System.out.printf( "Queue q added element: %d%n", 15 ); | |
System.out.printf( "Queue q first element: %d%n", q.element() ); | |
System.out.printf( "Queue q removed first element: %d%n", q.remove() ); | |
System.out.printf( "Queue q first element is %d%n", q.element() ); | |
System.out.printf( "Queue q last element: %d%n", q.peekLast() ); | |
System.out.printf( "Queue q is %s%n", q.isEmpty() ? "empty" : "not empty" ); | |
System.out.printf( "Queue q size is %d%n", q.size() ); | |
for (int i = 0; i < 200; ++i ) | |
q.add(i); | |
System.out.println(q); | |
try { | |
for (int i = 0; i < 100; ++i ) | |
q.add(20 + i*5); | |
} | |
catch (Exception ex) { | |
System.out.println( ex ); | |
} | |
try { | |
q.clear(); | |
q.remove(); | |
} | |
catch (Exception ex) { | |
System.out.println( ex ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment