package ru.matevosyan.start;

import java.util.Scanner;

/**
 * Class BasicAction implements interface UserAction.
 * Created for override key and info methods in this class.
 * Created on 07.12.2016.
 * @since 1.0
 * @version 1.0
 * @author Matevosyan Vardan
 */

public class ConsoleInput implements Input {

    /**
     * variable scanner for reading user input data.
     */

    private Scanner scanner = new Scanner(System.in);

    /**
     * Override interface Inputs method ask.
     * @param question use for showing messages to user
     * @return user reading data
     */

    @Override
    public String ask(String question) throws NullPointerException {

        System.out.print(question);
        return scanner.nextLine();

    }

    @Override
    public int ask(String question, int[] range) throws MenuOutException {
        int key = Integer.valueOf(this.ask(question));
        boolean exist = false;
        for (int value : range) {
            if (value == key) {
                exist = true;
                break;
            }
        }

        if (exist) {
            return key;
        } else {
            throw new MenuOutException("Out of menu range. ");
        }

    }

    @Override
    public int ask(String question, String[] rangeIds) throws NumberFormatException {
        String userId = ask(question);
        boolean exist = false;

        for (String gettingId : rangeIds) {
           if (Integer.parseInt(gettingId) == Integer.parseInt(userId)) {
                exist = true;
                break;
            }
        }

        if (exist) {
            return  Integer.parseInt(userId);
        } else {
            throw new NumberFormatException("Such item with this id does not exist. Please try again");
        }
    }
}

@@ -23,16 +23,44 @@
 start;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -77,16 +77,16 @@
 canner;%0A
-
 %0A/**%0A * 
@@ -825,13 +825,26 @@
 on, 
-int%5B%5D
+ArrayList%3CInteger%3E
  ran
@@ -1250,577 +1250,6 @@
  %7D%0A%0A
-    @Override%0A    public int ask(String question, String%5B%5D rangeIds) throws NumberFormatException %7B%0A        String userId = ask(question);%0A        boolean exist = false;%0A%0A        for (String gettingId : rangeIds) %7B%0A           if (Integer.parseInt(gettingId) == Integer.parseInt(userId)) %7B%0A                exist = true;%0A                break;%0A            %7D%0A        %7D%0A%0A        if (exist) %7B%0A            return  Integer.parseInt(userId);%0A        %7D else %7B%0A            throw new NumberFormatException(%22Such item with this id does not exist. Please try again%22);%0A        %7D%0A    %7D%0A
 %7D%0A

change all array to arrayList