package ru.job4j;

import java.util.Iterator;

/**
 * Task 4.1.2
 * Create Iterator even numbers
 *
 * @author Anton Vasilyuk on 03.06.2017.
 * @version 1.0
 * @since 0.1
 */

public class IteratorEvenNumbers implements Iterator {

    /**.
     * @values is array numbers
     */
    private int[] values;

    /**.
     * @index is index array
     */
    private int index = 0;

    /**.
     * Constructor for class IteratorEvenNumber
     * @param values is array numbers
     */
    public IteratorEvenNumbers(int[] values) {
        this.values = values;
    }

    /**.
     * Check latest index
     * @return boolean
     */
    @Override
    public boolean hasNext() {
        return this.values.length > index;
    }

    /**
     * Realisation iterator for even number
     * @return object on this position
     */
    @Override
    public Object next() {
        if(hasNext()) {
            while ((this.values[index] % 2) != 0) {
                index++;
                }
            }
        return this.values[index++];
    }
}


@@ -38,16 +38,57 @@
 terator;
+%0Aimport java.util.NoSuchElementException;
 %0A%0A/**%0A *
@@ -706,32 +706,152 @@
 ean hasNext() %7B%0A
+        if (this.values == null) %7B%0A            throw new NoSuchElementException(%22No element in this array.%22);%0A        %7D%0A
         return t

add file for chapter_003_4.1.2