package ru.job4j.tracker.controller;

/**
 * This class uses for test.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 14.04.2017
 */
public class StubInput implements Input {

    /**
     * parameter answers uses to implement users input.
     */
    private String[] answers;
    /**
     * parameter index find need String from array of answers.
     */
    private int index = 0;

    /**
     * constructor of StubInput class.
     *
     * @param answers is array of answer
     */
    public StubInput(String[] answers) {
        this.answers = answers;
    }

    /**
     * method return answer.
     *
     * @param question is question
     * @return answer
     */
    @Override
    public String ask(String question) {
        return answers[index++];
    }

}

@@ -31,16 +31,78 @@
 oller;%0A%0A
+import ru.job4j.tracker.exceptions.IndexOutOfRangeException;%0A%0A
 /**%0A * T
@@ -861,10 +861,712 @@
 %0A    %7D%0A%0A
+    /**%0A     * method ask data from user and validate this data to actions.%0A     *%0A     * @param question is question%0A     * @param range is range of integer%0A     * @return%0A     * @throws IndexOutOfRangeException%0A     */%0A    @Override%0A    public int ask(String question, int%5B%5D range) throws IndexOutOfRangeException %7B%0A%0A        boolean exist = false;%0A%0A        int key = Integer.valueOf(ask(question));%0A%0A        for (int value : range) %7B%0A%0A            if (value == key) %7B%0A                exist = true;%0A                break;%0A            %7D%0A%0A        %7D%0A%0A        if (exist) %7B%0A            return key;%0A        %7D else %7B%0A            throw new IndexOutOfRangeException(%22Incorrect menu action.%22);%0A        %7D%0A%0A    %7D%0A%0A
 %7D%0A

Refactor StubInput.java