class QueueOfCustomers {

    private Customer[] waiting;
    private int head;
    private int tail;
   
    public QueueOfCustomers(int capacity) {
        waiting = new Customer[capacity];
        head = -1;
        tail = -1;
    }

    public void insert(Customer cust) {
        if (isFull()) {
            return;
        }
        if (isEmpty()) {
            head = 0;
            tail = 0;
        } else {
            int newTail = (tail + 1) % waiting.length;
            if (head == newTail) {
	            return;
            } 
            tail = newTail;
        }
        waiting[tail] = cust;
    }

    public void remove() {
        if (isEmpty()) {
            return;
        }
        if (head == tail) {
	        head = -1;
            tail = -1;
        } else {
	        head = (head + 1) % waiting.length;
        }
   }

    public Customer getFront() {
        if (isEmpty()) {
            return null;
        }
        return waiting[head];
    }

    public boolean isEmpty() {
        return head == -1;
    }

    public boolean isFull() {
        return (length() == waiting.length);
    }

    public int length() {
        int length;
        if (head == -1) {
            return 0;
        } else if (head > tail) {
            length = waiting.length - head + tail + 1;
        } else {
            length = tail - head + 1;
        }
        return length;
    }

    public String toString() {
        String s = "Queue: [ ";
        if (! isEmpty()) {
            int idx = head;
            for (int i = 0; i < length(); i = i + 1) {
	            s = s + waiting[idx] + " ";
                idx = (idx == waiting.length - 1) ? 0 : idx + 1;
            }
        }
        s = s + "]";
        return s;
    }
}
