package ru.matevosyan;

/**
 * EvenNumber class.
 * Created on 03.05.2017.
 * @author Matevosyan Vardan
 * @version 1.0
 */

public class EvenNumber implements ArrayIterator {

    private int index = 0;
    private int j = 0;
    private final int[] array;

    /**
     * EvenNumber constructor.
     * @param array an array.
     */

    public EvenNumber(int[] array) {
        this.array = array;
    }

    /**
     * Override the next() method to iterate each element from an array.
     * @return even numbers from an array.
     */

    @Override
    public int next() {
        int value = 0;
        for (int i = index++; i < array.length; i++) {
            if (array[i] % 2 == 0) {
                value = i;
                break;
            } else {
                index++;
            }
        }
        return array[value];
    }

    /**
     * Override hasNext() method to check if eny of elements are in array to read, looking to next() pointer.
     * @return true if there are any elements to read, else return false.
     */

    @Override
    public boolean hasNext() {
        return array.length > index;
    }
}

@@ -17,16 +17,58 @@
 osyan;%0A%0A
+import java.util.NoSuchElementException;%0A%0A
 /**%0A * E
@@ -255,17 +255,21 @@
 ate int 
-j
+value
  = 0;%0A  
@@ -612,24 +612,54 @@
 c int next()
+ throws NoSuchElementException
  %7B%0A        i
@@ -657,29 +657,30 @@
         int 
-value
+result
  = 0;%0A      
@@ -685,31 +685,34 @@
     
-for (int i = index++; i
+if (!check() && this.index
  %3C a
@@ -726,13 +726,8 @@
 ngth
-; i++
 ) %7B%0A
@@ -742,32 +742,70 @@
     
-if (array%5Bi%5D %25 2 == 0) %7B
+throw new NoSuchElementException(%22No such element exception%22);
 %0A   
@@ -809,24 +809,27 @@
         
+%7D%0A%0A
         
 value = 
@@ -824,86 +824,113 @@
     
-value = i;%0A                break;%0A            %7D else %7B%0A                index++
+while (this.index %3C this.array.length) %7B%0A            this.index++;%0A            result = this.array%5Bvalue%5D
 ;%0A  
@@ -931,33 +931,38 @@
 e%5D;%0A            
-%7D
+break;
 %0A        %7D%0A     
@@ -971,30 +971,28 @@
  return 
-array%5Bvalue%5D;%0A
+result;%0A    
     %7D%0A%0A 
@@ -1251,16 +1251,21 @@
  return 
+this.
 array.le
@@ -1276,18 +1276,391 @@
  %3E index
-;%0A    %7D
+ && check();%0A    %7D%0A%0A    public boolean check() %7B%0A        boolean hasEven = false;%0A        for (int i = this.index; i %3C this.array.length; i++) %7B%0A            if (this.array%5Bi%5D %25 2 == 0) %7B%0A                this.value = i;%0A                hasEven = true;%0A                break;%0A            %7D else %7B%0A                this.index++;%0A            %7D%0A        %7D%0A        return  hasEven;%0A    %7D%0A
 %0A%7D%0A

change logic in EvenNumber.java