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 {

    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;
    }

    public int ask(Tracker tracker) {
        boolean invalid = true;
        int value = -1;

        do {
            try {
                value = super.ask(tracker);
                invalid = false;
            } catch (IdExistException iee) {
                System.out.println("Such item with this id does not exist. Please try again");
            } catch (NumberFormatException nfe) {
                System.out.println("Please enter validate data again");
            }
        } while (invalid);

        return value;
    }

}


@@ -754,23 +754,42 @@
 ask(
-Tracker tracker
+String question, String%5B%5D rangeIds
 ) %7B%0A
@@ -914,15 +914,34 @@
 ask(
-tracker
+%22Enter items id%22, rangeIds
 );%0A 
@@ -985,24 +985,26 @@
        %7D
+  
  catch (
 IdExistE
@@ -999,14 +999,19 @@
 ch (
-IdExis
+NumberForma
 tExc
@@ -1021,10 +1021,10 @@
 ion 
-ie
+nf
 e) %7B
@@ -1110,133 +1110,16 @@
 ase 
-try again%22);%0A            %7D catch (NumberFormatException nfe) %7B%0A                System.out.println(%22Please enter validate data
+enter id
  aga

edit ValidateInput.java