package ru.job4j.tracker.ui;

import ru.job4j.tracker.controller.IAction;
import ru.job4j.tracker.controller.Input;
import ru.job4j.tracker.controller.Tracker;
import ru.job4j.tracker.controller.UserAction;

/**
 * This class contain main method.
 *
 * @author Kucykh Vasily (mailto:basil135@mail.ru)
 * @version $Id$
 * @since 18.04.2017
 */
public class StartUI {

    /**
     * user's selection of menu.
     */
    private int key;
    /**
     * object of interface Input.
     */
    private Input input;
    /**
     * object of class Tracker.
     */
    private Tracker tracker;

    /**
     * method main.
     *
     * @param args input arguments
     */
    public static void main(String[] args) {


        Input input = new ConsoleInput();
        Tracker tracker = new Tracker();

        StartUI startUI = new StartUI(input, tracker);

        startUI.init();

    }

    /**
     * constructor.
     *
     * @param input is object of interface Input
     * @param tracker is object of class Tracker
     */
    public StartUI(Input input, Tracker tracker) {
        this.input = input;
        this.tracker = tracker;
    }

    /**
     * method initializes class.
     */
    public void init() {

        UserAction userAction = new UserAction(this.input, this.tracker);
        //UserAction.UpdateItem updateItem = userAction.new UpdateItem();
        userAction.fillActions();

        do {

            System.out.println(userAction.actionsToString());
            key = Integer.valueOf(input.ask("\nplease type your key:\n"));
            IAction action = userAction.select(key);
            System.out.println(action.execute(input, tracker));

        } while (key != 6);

    }

}

@@ -199,16 +199,127 @@
 rAction;
+%0Aimport ru.job4j.tracker.controller.ValidateInput;%0Aimport ru.job4j.tracker.exceptions.IndexOutOfRangeException;
 %0A%0A/**%0A *
@@ -764,16 +764,85 @@
 guments%0A
+     * @throws IndexOutOfRangeException if users type invalid action%0A
      */%0A
@@ -883,16 +883,48 @@
 %5B%5D args)
+ throws IndexOutOfRangeException
  %7B%0A%0A%0A   
@@ -950,14 +950,15 @@
 new 
-Consol
+Validat
 eInp
@@ -1403,32 +1403,140 @@
    *
-/%0A    public void init()
+%0A     * @throws IndexOutOfRangeException if users type invalid action%0A     */%0A    public void init() throws IndexOutOfRangeException
  %7B%0A%0A
@@ -1613,82 +1613,8 @@
 r);%0A
-        //UserAction.UpdateItem updateItem = userAction.new UpdateItem();%0A
     
@@ -1716,24 +1716,25 @@
 oString());%0A
+%0A
             
@@ -1792,20 +1792,53 @@
  key:%5Cn%22
+, userAction.getRangeOfActions()
 ));%0A
+%0A
         

Refactor StartUI.java