from container import Container


def container_cycle(c, i):
    """
    Cycle i items through Container c.
        self._contents[self._key] = obj

    @param Container c: container to cycle through
    @param int i: number of items to cycle through c
    @rtype: None
    """
    for n in range(i):
        c.add(n)

    # Replacing the while loop below with this print statement, should result in
    # the items getting printed by using the __str__ method of the Container,
    # which removes them one by one and produces a user-friendly string.
    # print(c)

    while not c.is_empty():
        print(c.remove())

    # Adding this should trigger an EmptyContainerException, yay!
    # c.remove()

if __name__ == "__main__":
    from stack import Stack
    from sack import Sack
    L = [Stack(), Sack()]
    for s in L:
        print("\nCycling through {}".format(s))
        container_cycle(s, 10)
