Question: Complete the implementation of the isEmpty(), first(), size() and toString() methods. Also create a main() method class to write two or more test scenarios that
Complete the implementation of the isEmpty(), first(), size() and toString() methods. Also create a main() method class to write two or more test scenarios that will demonstrate the queue operation of all public methods including a scenario that adds values beyond the original capacity of the queue. Instantiating each queue with a relatively small capacity is recommended. Demonstrate that you can instantiate CircularArrayQueue classes with different data types, enqueue several items, dequeue several items, display the queue contents after each operation, attempt dequeueing from an empty queue.
Please add comments so I can understand your code.
CircularArrayQueue.java
public class CircularArrayQueue
EmptyCollectionException.java
public class EmptyCollectionException extends RuntimeException { public EmptyCollectionException(String collection) { super("The " + collection + " is empty."); } }
QueueADT.java
public interface QueueADT
public T dequeue();
public T first(); public boolean isEmpty();
public int size();
public String toString(); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
