package cpsc2150.MyDeque;

import java.util.*;

/**
 * Class that implements the IDeque interface to override the toString method.
 *
 */
public abstract class AbsDeque implements IDeque {

    /**
     * Creates a string representation of the values in the deque.
     *
     * @post toString = [ string representation of #self ] and
     *       self = #self
     */
    @Override
    public String toString() {

        String deque = "<";
        // Loop through indexes in q
        for (int i = 1; i <= length(); i++) {

            // Call get function to store next value
            int current = get(i);

            // Check if i is equal to length of q
            if (i != length()) {

                // Add value to string with comma and space
                deque += current;
                deque += ", ";

            } else {

                // Add value to string
                deque += current;

            }

        }

        deque += ">";

        return deque;

    }

}
