package ru.job4j.start;
import ru.job4j.models.Item;
import ru.job4j.models.Task;

/**StartUI -- It is for manage the program.
 *Example '<Milk> + <12>', it's mean that you should write: Milk 12
 *@author Anton Oleynikov
 *@version 1
 */
public class StartUI {
    /**
     *input input.
     */
    private Input input;
    /**
     * Tracker.
     */
    private Tracker tracker;
    /**
     *Constructor.
     * @param input input
     * @param tracker tracker
     */
    public StartUI(Input input, Tracker tracker) {
        this.input = input;
        this.tracker = tracker;
    }
    /**
     *@param args from console
     *@exception Exception Exception
     */
    public static void main(String[] args) throws Exception {
        Input input = new ConsoleInput();
        new StartUI(input, new Tracker()).init();
    }
    /**
     *@exception Exception Exception
     */
    public void init() throws Exception {
        while (true) {
            System.out.printf("1 Add %n 2 update %n 3 delete %n 4 findAll %n 5 filterByName %n 6 findById %n 7 End");
            //System.out.printf("1 Add %n 2 update %n 3 delete %n 7 End");
            String answer = input.ask("Write number ");
            if (answer.equals("1")) {
                this.tracker.add(new Task(input.ask("enter the task's name: "), input.ask("enter description: ")));
            } else if (answer.equals("2")) {
                this.tracker.update(new Task(input.ask("enter the task's name: "), input.ask("enter description: ")), input.ask("write id: "));
            } else if (answer.equals("3")) {
                this.tracker.delete(this.tracker.findById(input.ask("write id: ")));

            } else if (answer.equals("4")) {
                print(this.tracker.findAll());
            } else if (answer.equals("5")) {
                print(this.tracker.filterByName(input.ask("write name: ")));
            } else if (answer.equals("6")) {
                print(this.tracker.findById(input.ask("write id: ")));

            } else if (answer.equals("7")) {
                break;
            }
        }
    }
    /**
     *
     * @param items items.
     */
    public void print(Item[] items) {
        for (Item item : items) {
            System.out.println(item.getName() + " " + item.getDescription() + " " + item.getId());
        }
    }

    /**
     *
     * @param item item.
     */
    public void print(Item item) {
        System.out.println(item.getName() + " " + item.getDescription() + " " + item.getId());
    }
}
@@ -379,24 +379,477 @@
 er;%0A    /**%0A
+     * one.%0A     */%0A    static final String one = %221%22;%0A    /**%0A     * two.%0A     */%0A    static final String two = %222%22;%0A    /**%0A     * three.%0A     */%0A    static final String three = %223%22;%0A    /**%0A     * four.%0A     */%0A    static final String four = %224%22;%0A    /**%0A     * five.%0A     */%0A    static final String five = %225%22;%0A    /**%0A     * six.%0A     */%0A    static final String six = %226%22;%0A    /**%0A     * seven.%0A     */%0A    static final String seven = %227%22;%0A    /**%0A
      *Constr
@@ -855,16 +855,16 @@
 ructor.%0A
-
      * @
@@ -1367,32 +1367,33 @@
 ows Exception %7B%0A
+%0A
         while (t
@@ -1664,30 +1664,27 @@
     if (
-answer
+one
 .equals(
 %221%22)) %7B%0A
@@ -1675,19 +1675,22 @@
 .equals(
-%221%22
+answer
 )) %7B%0A   
@@ -1825,30 +1825,27 @@
 lse if (
-answer
+two
 .equals(
 %222%22)) %7B%0A
@@ -1836,19 +1836,22 @@
 .equals(
-%222%22
+answer
 )) %7B%0A   
@@ -2014,30 +2014,29 @@
 lse if (
-answer
+three
 .equals(
 %223%22)) %7B%0A
@@ -2027,19 +2027,22 @@
 .equals(
-%223%22
+answer
 )) %7B%0A   
@@ -2139,37 +2139,35 @@
      %7D else if (
-answe
+fou
 r.equals(%224%22)) %7B
@@ -2159,19 +2159,22 @@
 .equals(
-%224%22
+answer
 )) %7B%0A   
@@ -2240,30 +2240,28 @@
 lse if (
-answer
+five
 .equals(
 %225%22)) %7B%0A
@@ -2252,19 +2252,22 @@
 .equals(
-%225%22
+answer
 )) %7B%0A   
@@ -2363,30 +2363,27 @@
 lse if (
-answer
+six
 .equals(
 %226%22)) %7B%0A
@@ -2374,19 +2374,22 @@
 .equals(
-%226%22
+answer
 )) %7B%0A   
@@ -2484,22 +2484,21 @@
 if (
-answer
+seven
 .equals(
 %227%22)
@@ -2493,19 +2493,22 @@
 .equals(
-%227%22
+answer
 )) %7B%0A   

update 11.0