/**
   * This method allows the queue to be printed out as a string.
   *
   * @return The string that represents all the values held in the array.
   */
  public String toString() {
    String result = "";
    LinearNode<T> current = head;

    while (current != null) {
      result = result + (current.getElement()).toString() + "\n";
      current = current.getNext();
    }
    return result;
  }
  /**
   * This method allows the element at the top of the queue to de removed.
   *
   * @return The element that is removed
   * @throws EmptyCollectionException The exception when the queue is empty.
   */
  public T dequeue() throws EmptyCollectionException {
    if (isEmpty()) {
      throw new EmptyCollectionException("queue");
    }
    T result = head.getElement();
    head = head.getNext();
    count--;

    if (isEmpty()) {
      tail = null;
    }
    return result;
  }
 /**
  * This method returns the element at the top of the queue if there is an element there.
  *
  * @return The first element in the queue.
  */
 public T first() {
   if (isEmpty()) {
     throw new EmptyCollectionException("queue");
   }
   return head.getElement();
 }