package ru.apetrov.checkEvenNumbers;

import java.util.Iterator;

/**
 * Created by Andrey on 25.02.2017.
 */
public class CheckEvenNumbers implements Iterator {

    private final int[] values;

    private int index = 0;

    public CheckEvenNumbers(int[] values) {
        this.values = values;
    }

    @Override
    public boolean hasNext() {
        boolean result = false;
        if (this.values.length > this.index && this.isEven(this.index)) {
            result = true;
        }
        return result;
    }

    @Override
    public Object next() {
        Integer result = null;
        if (this.isEven(this.index)) {
            result = this.values[index];
        }
        index++;
        return result;
    }

    private boolean isEven(int index) {
        boolean result = false;
        if (this.values[index] % 2 == 0) {
            result = true;
        }
        return result;
    }
}

@@ -656,24 +656,29 @@
 this.values%5B
+this.
 index%5D;%0A    
@@ -691,16 +691,21 @@
         
+this.
 index++;

update CheckEvenNumbers