package ru.matevosyan.start;
import ru.matevosyan.models.Item;
import java.util.Arrays;

/**
 * Created class StartUI for starting the program.
 * Created on 25.11.2016.
 * @since 1.0
 * @author Matevosyan Vardan
 * @version 1.0
 */

public class StartUI {

    /**
     * Input instance variable input.
     */

    private Input input;

    /**
     * Input instance variable tracker.
     */

    private Tracker tracker;

    /**
     * Constructor for StartUI.
     * @param input for assign ot enter data to the program.
     * @param tracker for take the Tracker state.
     */

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

    /**
     * Method for initialization program menu and interaction with user.
     */

    public void init() {

        /**
         * variables for user check.
         */

        final String exit = "y";

        //System.out.println("___M_E_N_U___ \r\n" + "1. Add Item \r\n" + "2. Edit Item \r\n" + "3. Remove Item \r\n" + "4. Add comment\r\n" + "5. Find by id \r\n" + "6. Find by name \r\n" + "7. Find by date \r\n" + "8. Get all items\r\n" + "9. Exit\r\n");

        MenuTracker menu = new MenuTracker(this.input, this.tracker);
        menu.fillAction();
        //String number = input.ask("Please enter the number of Task's: ");

        do {
            menu.show();
            String key = input.ask("Select number of Tasks ");
            menu.select(key);
/*
            if (Integer.parseInt(number) == one) {

                String name = input.ask("Please enter the Task's name: ");
                String description = input.ask("Please enter the Task's description: ");
                this.tracker.add(new Item(name, description));

            }

            if (Integer.parseInt(number) == two) {

                String id = input.ask("Please enter the Task's id: ");
                Item item = this.tracker.findById(id);

                String name = input.ask("Please enter the Task's name: ");
                item.setName(name);

                String description = input.ask("Please enter the Task's description: ");
                item.setDescription(description);

                this.tracker.editItem(item);
            }

            if (Integer.parseInt(number) == three) {

                String id = input.ask("Please enter the Task's id: ");
                this.tracker.deleteItem(id);

            }

            if (Integer.parseInt(number) == four) {

                String id = input.ask("Please enter the Task's id: ");
                String comment = input.ask("Please enter the Task's comment: ");

                Item findItem = this.tracker.findById(id);
                this.tracker.addComment(findItem, comment);

            }

            if (Integer.parseInt(number) == five) {

                String id = input.ask("Please enter the Task's id: ");
                Item itemFindById = this.tracker.findById(id);
                System.out.println(itemFindById);

            }

            if (Integer.parseInt(number) == six) {

                String name = input.ask("Please enter the Task's name: ");
                Item itemFindByName = this.tracker.findByName(name);
                System.out.println(itemFindByName);

            }

            if (Integer.parseInt(number) == seven) {

                String date = input.ask("Please enter the Task's date: ");
                Item itemFindByDate = this.tracker.findByDate(Long.parseLong(date));
                System.out.println(itemFindByDate);

            }

            if (Integer.parseInt(number) == eight) {

                System.out.println(Arrays.toString(this.tracker.getAll()));

            }

           String askForContinue = input.ask("Would you like to continue, y/n?: ");

            if (askForContinue.equals("y")) {

                number = input.ask("Please enter the number of Task's: ");

            } else if (askForContinue.equals("n")) {

                number = "9";

            }
            */
        } while (!exit.equals(this.input.ask("Esit? (y) ")));

    }

    /**
     * The static main method which is starting our program.
     * @param args is the array argument that pass to main method
     */

    public static void main(String[] args) {

        /**
         * Instance variable StartUI and call the method init.
         */

        Input input = new ConsoleInput();
        new StartUI(input, new Tracker()).init();

    }

}

@@ -26,68 +26,8 @@
 rt;%0A
-import ru.matevosyan.models.Item;%0Aimport java.util.Arrays;%0A%0A
 /**%0A
@@ -852,266 +852,8 @@
 y%22;%0A
-%0A        //System.out.println(%22___M_E_N_U___ %5Cr%5Cn%22 + %221. Add Item %5Cr%5Cn%22 + %222. Edit Item %5Cr%5Cn%22 + %223. Remove Item %5Cr%5Cn%22 + %224. Add comment%5Cr%5Cn%22 + %225. Find by id %5Cr%5Cn%22 + %226. Find by name %5Cr%5Cn%22 + %227. Find by date %5Cr%5Cn%22 + %228. Get all items%5Cr%5Cn%22 + %229. Exit%5Cr%5Cn%22);%0A%0A
     
@@ -948,84 +948,8 @@
 n();
-%0A        //String number = input.ask(%22Please enter the number of Task's: %22);
 %0A%0A  
@@ -959,16 +959,17 @@
    do %7B%0A
+%0A
         
@@ -1082,2590 +1082,8 @@
 y);%0A
-/*%0A            if (Integer.parseInt(number) == one) %7B%0A%0A                String name = input.ask(%22Please enter the Task's name: %22);%0A                String description = input.ask(%22Please enter the Task's description: %22);%0A                this.tracker.add(new Item(name, description));%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == two) %7B%0A%0A                String id = input.ask(%22Please enter the Task's id: %22);%0A                Item item = this.tracker.findById(id);%0A%0A                String name = input.ask(%22Please enter the Task's name: %22);%0A                item.setName(name);%0A%0A                String description = input.ask(%22Please enter the Task's description: %22);%0A                item.setDescription(description);%0A%0A                this.tracker.editItem(item);%0A            %7D%0A%0A            if (Integer.parseInt(number) == three) %7B%0A%0A                String id = input.ask(%22Please enter the Task's id: %22);%0A                this.tracker.deleteItem(id);%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == four) %7B%0A%0A                String id = input.ask(%22Please enter the Task's id: %22);%0A                String comment = input.ask(%22Please enter the Task's comment: %22);%0A%0A                Item findItem = this.tracker.findById(id);%0A                this.tracker.addComment(findItem, comment);%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == five) %7B%0A%0A                String id = input.ask(%22Please enter the Task's id: %22);%0A                Item itemFindById = this.tracker.findById(id);%0A                System.out.println(itemFindById);%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == six) %7B%0A%0A                String name = input.ask(%22Please enter the Task's name: %22);%0A                Item itemFindByName = this.tracker.findByName(name);%0A                System.out.println(itemFindByName);%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == seven) %7B%0A%0A                String date = input.ask(%22Please enter the Task's date: %22);%0A                Item itemFindByDate = this.tracker.findByDate(Long.parseLong(date));%0A                System.out.println(itemFindByDate);%0A%0A            %7D%0A%0A            if (Integer.parseInt(number) == eight) %7B%0A%0A                System.out.println(Arrays.toString(this.tracker.getAll()));%0A%0A            %7D%0A%0A           String askForContinue = input.ask(%22Would you like to continue, y/n?: %22);%0A%0A            if (askForContinue.equals(%22y%22)) %7B%0A%0A                number = input.ask(%22Please enter the number of Task's: %22);%0A%0A            %7D else if (askForContinue.equals(%22n%22)) %7B%0A%0A                number = %229%22;%0A%0A            %7D%0A            */
 %0A   

delete code comments.java