Skip to content

Instantly share code, notes, and snippets.

@cdduarte
Created June 5, 2014 04:05
Show Gist options
  • Save cdduarte/71b30527beefb2082d85 to your computer and use it in GitHub Desktop.
Save cdduarte/71b30527beefb2082d85 to your computer and use it in GitHub Desktop.
/**
* 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