There are two parts to this assignment
Implement OurQueue<E> with a linked structure that has front and back external references. The interface is below (and in OurQueue.java)
Write a waiting line simulation to determine the longest line, average wait time, and customers served at Ike's Coffee shop (see the methods an unit test stored in WaitingLineTest.java )
import java.util.NoSuchElementException;
public interface OurQueue<E> {
// Return true if this queue has 0 elements
public boolean isEmpty();
// Store a reference to any object at the end
// Must be O(1)
public void add(E newEl);
// Return a reference to the object at the
// front of this queue
public E peek() throws NoSuchElementException;
// Remove the reference to the object at the front of this Q
// Must be O(1)
public E remove() throws NoSuchElementException;
// Return the number of elements in this queue
// Must be O(1)
public int size();
}
Class Waiting line has 4 methods plus one constructor
WaitingLine wl = new WaitingLine(1.5, 60);
assertEquals(0.0, wl.averageWaitTime(), 0.1);
assertEquals(0, w1.customerServed());
assertEquals(0, wl.stillWaiting());
// 3 hour simulations (60 minutes in an hour)
// -999 is the seed for the Random object constructor
wl.runSimulation(3 * 60, -999);
Added after Friday (use a seed for Random, use the given unit test to ensure you can get 100%)
From the API: If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers.
Method runSimulation should begin like this:
public void runSimulation(int totalMinutes, int seed) {
Random generator = new Random(seed);
q = new LinkedQueue<Integer>();
Use this unit test stored as WaitingLineTest.java that prints the expected results and has very generous assertions