package ru.job4j;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * 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() {
        if (this.values == null) {
            throw new NoSuchElementException("No element in this array.");
        }
        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++];
    }
}


@@ -328,24 +328,26 @@
 rivate int%5B%5D
+%5B%5D
  values;%0A%0A  
@@ -418,16 +418,179 @@
 x = 0;%0A%0A
+    /**.%0A     * @index is colon array%0A     */%0A    private int colon = 0;%0A%0A    /**.%0A     * Amount returned even numbers%0A     */%0A    private int returnCheckNum = 0;%0A
     /**.
@@ -720,16 +720,18 @@
 rs(int%5B%5D
+%5B%5D
  values)
@@ -873,32 +873,33 @@
 ean hasNext() %7B%0A
+%0A
         if (this
@@ -1002,39 +1002,366 @@
       %7D%0A        
-return 
+int checkNum = 0;%0A        for (int i = 0; i %3C this.values.length; i++) %7B%0A            for (int j = 0; j %3C this.values%5Bi%5D.length; j++) %7B%0A                if ((this.values%5Bi%5D%5Bj%5D %25 2) == 0) %7BcheckNum++;%7D%0A            %7D%0A        %7D%0A        if (checkNum == 0) %7Breturn false;%7D%0A        if (returnCheckNum == checkNum) %7Breturn false;%7D%0A        if (
 this.values.leng
@@ -1351,24 +1351,31 @@
 (this.values
+%5Bcolon%5D
 .length %3E in
@@ -1377,17 +1377,76 @@
  %3E index
-;
+) %7B%0A            return true;%0A        %7D else  %7Breturn false;%7D
 %0A    %7D%0A%0A
@@ -1595,16 +1595,17 @@
       if
+ 
 (hasNext
@@ -1638,24 +1638,31 @@
 this.values%5B
+colon%5D%5B
 index%5D %25 2) 
@@ -1710,27 +1710,259 @@
     
-    %7D%0A            %7D
+%7D%0A        %7D else %7B%0A            colon++;%0A            index = 0;%0A            if (hasNext()) %7B%0A                while ((this.values%5Bcolon%5D%5Bindex%5D %25 2) != 0) %7B%0A                    index++;%0A                %7D%0A            %7D%0A        %7D%0A        returnCheckNum++;
 %0A   
@@ -1985,16 +1985,23 @@
 .values%5B
+colon%5D%5B
 index++%5D

add file for chapter_003_4.1.2