package ru.matevosyan.start;

/**
 * Created for valid input data.
 * Created on 27.12.2016.
 * @since 1.0
 * @version 1.0
 * @author Matevosyan Vardan
 */

public class ValidateInput extends ConsoleInput {

    /**
     * Method ask extend ConsoleInput method and use for catch throwing exception.
     * @param question for ask the question to user
     * @param range available userAction in menu
     * @return value userAction invoking parent ask method
     */

    public int ask(String question, int[] range) {

        boolean invalid = true;
        int value = -1;

        do {
            try {
                value = super.ask(question, range);
                invalid = false;
            } catch (MenuOutException moe) {
                System.out.println("Please select key from menu");
            } catch (NumberFormatException nfe) {
                System.out.println("Please enter validate data again");
            }
        } while (invalid);

        return value;
    }

    /**
     * Method ask extend ConsoleInput method and use for catch throwing exception.
     * @param question or ask the question to user
     * @param rangeIds available array items id
     * @return id value
     */

    public int ask(String question, String[] rangeIds) {
        boolean invalid = true;
        int value = -1;

        do {
            try {
                value = super.ask("Enter items id", rangeIds);
                invalid = false;
            }   catch (NumberFormatException nfe) {
                System.out.println("Such item with this id does not exist. Please enter id again");
            }
        } while (invalid);

        return value;
    }

}


@@ -23,16 +23,45 @@
 start;%0A%0A
+import java.util.ArrayList;%0A%0A
 /**%0A * C
@@ -530,13 +530,26 @@
 on, 
-int%5B%5D
+ArrayList%3CInteger%3E
  ran
@@ -882,32 +882,32 @@
 xception nfe) %7B%0A
+
                 
@@ -1037,694 +1037,7 @@
  %7D%0A%0A
-    /**%0A     * Method ask extend ConsoleInput method and use for catch throwing exception.%0A     * @param question or ask the question to user%0A     * @param rangeIds available array items id%0A     * @return id value%0A     */%0A%0A    public int ask(String question, String%5B%5D rangeIds) %7B%0A        boolean invalid = true;%0A        int value = -1;%0A%0A        do %7B%0A            try %7B%0A                value = super.ask(%22Enter items id%22, rangeIds);%0A                invalid = false;%0A            %7D   catch (NumberFormatException nfe) %7B%0A                System.out.println(%22Such item with this id does not exist. Please enter id again%22);%0A            %7D%0A        %7D while (invalid);%0A%0A        return value;%0A    %7D%0A%0A
 %7D%0A%0A

delete one method