package shapes; import java.util.ArrayList; public class ShapeList extends ArrayList { private int currentIndex = 0; public Shape next() { if (size() == 0) return null; if (currentIndex++ >= size() - 1) { currentIndex = 0; } return get(currentIndex); } }