Here is our sample solution for the Main class:
public class Main
{
public static void main(String[] args)
{
FixedSizeContractQueue queue;
// Test 1 of 2.
System.out.println("\nTest 1: create a queue of capacity 4 and fill it up");
queue = new FixedSizeContractQueue(4);
for (int i=0; i<4; i++)
{
if (queue.isFull())
{
System.out.println("The queue is full - cannot add item");
}
else
{
queue.add(i*10); // modify this to ensure contract holds
}
}
System.out.println("Queue contents: " + queue);
// Test 2 of 2.
System.out.println("\nTest 2: try to add one item too many");
if (queue.isFull())
{
System.out.println("The queue is full - cannot add item");
}
else
{
queue.add(40); // modify this to ensure contract holds
}
System.out.println("Queue contents: " + queue);
}
}