package ru.matevosyan.start;

import ru.matevosyan.models.Item;

/**
 * Created by Admin on 21.12.2016.
 */
public class MenuTracker {

    private Input input;
    private Tracker tracker;
    private UserAction[] userAction = new UserAction[9];

    public MenuTracker(Input input, Tracker tracker) {
        this.input = input;
        this.tracker = tracker;
    }

    public void fillAction() {
        this.userAction[0] = new AddItem();
    }

    public void show() {
        for (UserAction userAction : this.userAction) {
            System.out.println(userAction.info());
        }
    }

    private class AddItem implements UserAction {
        public int key(){
            return 1;
        }
        public void execute(Input input, Tracker tracker) {
            String name = input.ask("Please enter the Task's name");
            String description = input.ask("Please enter the Task's description");
            tracker.add(new Item(name, description));
        }

        public String info() {
            return String.format("%s, %s", this.key(), " Add task");
        }
    }
}

@@ -77,22 +77,64 @@
 ted 
-by Admin
+class MenuTracker for add program menu.%0A * Created
  on 2
-1
+0
 .12.
@@ -143,12 +143,72 @@
 16.%0A
+ * @since 1.0%0A * @author Matevosyan Vardan%0A * @version 1.0%0A
  */%0A
+%0A
 publ
@@ -540,16 +540,204 @@
 Item();%0A
+        this.userAction%5B1%5D = new MenuTracker.ShowItems();%0A    %7D%0A%0A    public void select(String key) %7B%0A        this.userAction%5BInteger.parseInt(key) - 1%5D.execute(this.input, this.tracker);%0A
     %7D%0A%0A 
@@ -812,24 +812,66 @@
 erAction) %7B%0A
+            if (userAction != null) %7B%0A    
             
@@ -905,24 +905,38 @@
 on.info());%0A
+            %7D%0A
         %7D%0A  
@@ -936,24 +936,242 @@
    %7D%0A    %7D%0A%0A
+    /**%0A     * Created class AddItem for implements UserAction and add action to add items for user action.%0A     * Created on 20.12.2016.%0A     * @since 1.0%0A     * @author Matevosyan Vardan%0A     * @version 1.0%0A     */%0A%0A
     private 
@@ -1207,16 +1207,35 @@
 Action %7B
+%0A%0A        @Override
 %0A       
@@ -1277,32 +1277,50 @@
 rn 1;%0A        %7D%0A
+        @Override%0A
         public v
@@ -1428,16 +1428,17 @@
 k's name
+ 
 %22);%0A    
@@ -1512,16 +1512,17 @@
 cription
+ 
 %22);%0A    
@@ -1577,24 +1577,41 @@
 ;%0A        %7D%0A
+        @Override
 %0A        pub
@@ -1666,17 +1666,17 @@
 rmat(%22%25s
-,
+.
  %25s%22, th
@@ -1690,17 +1690,796 @@
 ), %22
- Add task
+Add new Item%22);%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * Created sctaric class ShowItems for implements UserAction and add action to show all items for user action.%0A     * Created on 20.12.2016.%0A     * @since 1.0%0A     * @author Matevosyan Vardan%0A     * @version 1.0%0A     */%0A%0A    private static class ShowItems implements UserAction %7B%0A%0A        @Override%0A        public int key()%7B%0A            return 2;%0A        %7D%0A        @Override%0A        public void execute(Input input, Tracker tracker) %7B%0A            for (Item item : tracker.getAll()) %7B%0A                System.out.println(String.format(%22%25s. %25s. %25s %22, item.getId(), item.getName(), item.getDescription()));%0A            %7D%0A        %7D%0A        @Override%0A        public String info() %7B%0A            return String.format(%22%25s. %25s%22, this.key(), %22Show items
 %22);%0A
@@ -2484,20 +2484,21 @@
 ;%0A        %7D%0A
+%0A
     %7D%0A%7D%0A

edit MenuTracker.java