package ru.job4j.tracker;

/**
 * @author Nikita Zenkin.
 * @version 1.
 * @since 07.06.2017.
 */
public class StartUI {
    /**
     * Input variable.
     */
    private Input input;
    /**
     * Output variable.
     */
    private Output output;

    /**
     * Constructor.
     * @param input Input class.
     * @param output Output class.
     */
    private StartUI(Input input, Output output) {
        this.input = input;
        this.output = output;
    }

    /**
     * initial method.
     */
    private void init() {
        String action = "";
        String lineSeparator = System.lineSeparator();
        String id, name, desc;
        Tracker tracker = new Tracker();
        while (!action.equals("6")) {
            action = input.ask(
                    "0.Add new item" + lineSeparator
                            + "1.Show all items" + lineSeparator
                            + "2.Edit item" + lineSeparator
                            + "3.Delete item" + lineSeparator
                            + "4.Find item by ID" + lineSeparator
                            + "5.Find items by name" + lineSeparator
                            + "6.Exit program" + lineSeparator
                            + "Select:" + lineSeparator);
           /* switch (action) {
                case "0":
                    name = input.ask("Enter name of new item: ");
                    desc = input.ask("Enter description of new item: ");
                    tracker.add(new Item(name, desc, 123));
                    System.out.print("You added new item!" + lineSeparator);
                    break;
                case "1":
                    output.printItems(tracker.findAll());
                    break;
                case "2":
                    id = input.ask("Enter id of item that you want to update: ");
                    name = input.ask("Enter new name of item: ");
                    desc = input.ask("Enter new description of item: ");
                    Item newItem = tracker.findById(id);
                    newItem.setName(name);
                    newItem.setDesc(desc);
                    tracker.update(newItem);
                    System.out.print(String.format("Item with ID %s updated %s", id, lineSeparator));
                    break;
                case "3":
                    id = input.ask("Enter id of item that you want to delete: ");
                    tracker.delete(tracker.findById(id));
                    System.out.print(String.format("Item with ID %s deleted %s", id, lineSeparator));
                    break;
                case "4":
                    id = input.ask("Enter id of item that you want to find: ");
                    output.printItem(tracker.findById(id));
                    break;
                case "5":
                    name = input.ask("Enter name of items you want to find: ");
                    output.printItems(tracker.findByName(name));
                    break;
                case "6":
                    break;
                default:
                    System.out.print("Please enter correct menu number!" + lineSeparator);
            }*/
        }
    }

    /**
     * Main.
     * @param args String[].
     */
    public static void main(String[] args) {
        Input input = new ConsoleInput();
        Output output = new ConsoleOutput();
        new StartUI(input, output).init();
    }
}

@@ -775,16 +775,72 @@
         
+new StringBuilder()%0A                            .append(
 %220.Add n
@@ -843,27 +843,33 @@
 dd new item%22
- + 
+).append(
 lineSeparato
@@ -861,32 +861,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -899,18 +899,24 @@
         
-+ 
+.append(
 %221.Show 
@@ -925,19 +925,25 @@
 l items%22
- + 
+).append(
 lineSepa
@@ -939,32 +939,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -977,18 +977,24 @@
         
-+ 
+.append(
 %222.Edit 
@@ -994,27 +994,33 @@
 2.Edit item%22
- + 
+).append(
 lineSeparato
@@ -1012,32 +1012,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -1050,18 +1050,24 @@
         
-+ 
+.append(
 %223.Delet
@@ -1073,19 +1073,25 @@
 te item%22
- + 
+).append(
 lineSepa
@@ -1087,32 +1087,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -1125,18 +1125,24 @@
         
-+ 
+.append(
 %224.Find 
@@ -1152,19 +1152,25 @@
 m by ID%22
- + 
+).append(
 lineSepa
@@ -1166,32 +1166,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -1204,18 +1204,24 @@
         
-+ 
+.append(
 %225.Find 
@@ -1234,19 +1234,25 @@
 by name%22
- + 
+).append(
 lineSepa
@@ -1248,32 +1248,33 @@
 nd(lineSeparator
+)
 %0A               
@@ -1286,18 +1286,24 @@
         
-+ 
+.append(
 %226.Exit 
@@ -1310,19 +1310,25 @@
 program%22
- + 
+).append(
 lineSepa
@@ -1332,16 +1332,17 @@
 eparator
+)
 %0A       
@@ -1362,18 +1362,24 @@
         
-+ 
+.append(
 %22Select:
@@ -1379,19 +1379,25 @@
 Select:%22
- + 
+).append(
 lineSepa
@@ -1394,32 +1394,44 @@
 d(lineSeparator)
+.toString())
 ;%0A           /* 
@@ -1426,19 +1426,16 @@
         
- /*
  switch 
@@ -3317,18 +3317,16 @@
        %7D
-*/
 %0A       

Undo comment to switch and replace String menu to StringBuilder menu.