Write a program that implements the Queue API (“QueueAPI.java”, provided with
documentation) using singly linked nodes and head/tail references as covered in lecture. A
code template has been provided for you – place your code in the appropriate methods. If a
method indicates an exception for some condition be sure to check and throw this when the
The Queue API extends the Iterable interface and adds the iterator() method.
You need to provide an implementation using either an anonymous class or a private inner
class. The returned iterator should throw an UnsupportedOperationException for the remove
method and does not need to check for concurrent modifications. The next() method should
also throw NoSuchElementException if the iterator has no more elements.
The iterator method, along with the other Queue API methods, have default
implementations in Queue.java. You need to modify them to correctly implement the
The methods defined in QueueAPI.java already have javadoc – use them (copy/paste
is fine) in your own implementation for the method documentation. However, documentation
rules still apply for any methods you add and the code in the methods that you add.
The toString and main method have already been implemented for you, do not change.
The main method takes in the file “operations.txt” for unit testing your code. Additionally, a
“Stdio.java” file is provided and used in the main, do not modify. You cannot change the
signature of the class, constructor, or existing method signatures. You will also need to add
one or more inner classes.
• Use the template provided for you
• Have a style (indentation, good variable names, etc.)
• Comment your code well (no need to over do it, just do it well)
You may not:
• Make your program part of a package.
• Use code from anywhere except your own brain.
• Name a folder with your gmu username
• Put your java files in the folder (but not your .class)
• Zip the folder (not just the files) and name the zip “username-pa3.zip”
• Submit to blackboard
• Non-submitted assignments
• Late assignments
• Non-compiling assignments
• Non-independent work
> java Queue operations.txt
Queue=[alpha, bravo, charlie]
1pt Submission Format
1pt Style and Comments
1pt Node class
2pts enqueue method
2pts dequeue method
2pts Iterator class/methods
1pt size, peek, isEmpty methods