class MyIterator<E> implements ReversibleIterator<E> {
        final private E[] array;
        final private int startIndex;
        final private int endIndex;
        final private boolean isReversed;
        private int index;

        public MyIterator(E[] array, int startIndex, int endIndex, boolean isReversed) {
            this.isReversed = isReversed;
            this.array = array;
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            index = isReversed ? endIndex : startIndex;
        }

        @Override
        public boolean hasNext() {<FILL_FUNCTION_BODY>}

        @Override
        public E next() {
            return isReversed ? array[--index] : array[index++];
        }

        @Override
        public boolean isReversed() {
            return isReversed;
        }
    }

            return isReversed ? index >= startIndex : index < endIndex;
        
<no_super_class>