package ru.job4j.start;

import ru.job4j.models.*;
import java.util.Date;


/**.
* It programm for ready apps tracker
*
* @author Anton Vasilyuk
* @version 1.0
* @since 0.1
*/

public class StartUI {

	/**.
	* @input input its object for interaction
	*/
	private Input input;

	/**.
	* It's constructor for this class
	* @param input input parametr object
	*/
	public StartUI(Input input, Tracker tracker) {
		this.input = input;
		tracker = new Tracker();
		this.tracker = tracker;
	}
	/**.
	* method for intaraction with apps tracker
	*/
	public void init() {
		Tracker tracker = new Tracker();
		String name;
		String desc;
		String id;
		int selection;
		public final int ADD = 0;
		public final int SHOWALL = 1;
		public final int EDIT = 2;
		public final int DELETE = 3;
		public final int FINDBYID = 4;
		public final int FINDBYNAME = 5;
		public final int EXIT = 6;
		do {
			do {
				System.out.println("Menu tracker:");
				System.out.println("0. Add new item");
				System.out.println("1. Show all item");
				System.out.println("2. Edit item");
				System.out.println("3. Delete item");
				System.out.println("4. Find item by id");
				System.out.println("5. Find items by name");
				System.out.println("6. Exit program");
				selection = Integer.valueOf(input.ask("Enter the action number:"));
			} while (selection < 0 && selection > 6);

			if (selection == ADD) {
				Date date = new Date();
				name = input.ask("Enter the name for item:");
				desc = input.ask("Enter the desc for item:");
				Item item = new Item(name, desc, date.getTime());
				tracker.add(item);
				System.out.println("Thanks you! Your wish fulfilled");
			}

			if (selection == SHOWALL) {
				Item[] array = tracker.findAll();
				for (int index = 0; index < array.length; index++) {
					System.out.println(array[index].getName() + ", " + array[index].getDesc());
				}
				System.out.println("Thanks you! Your wish fulfilled");
			}

			if (selection == EDIT) {
				Date date = new Date();
				id = input.ask("Enter the id for item:");
				name = input.ask("Enter the name for item:");
				desc = input.ask("Enter the desk for item:");
				Item item = new Item(name, desc, date.getTime());
				item.setId(id);
				tracker.update(item);
				System.out.println("Thanks you! Your wish fulfilled");
			}

			if (selection == DELETE) {
				id = input.ask("Enter the id for item:");
				tracker.delete(tracker.findById(id));
				System.out.println("Thanks you! Your wish fulfilled");
			}

			if (selection == FINDBYID) {
				id = input.ask("Enter the id for item:");
				Item item = tracker.findById(id);
				System.out.println(item.getName() + ", " + item.getDesc());
				System.out.println("Thanks you! Your wish fulfilled");
			}

			if (selection == FINDBYNAME) {
				name = input.ask("Enter the name for item:");
				Item[] items = tracker.findByName(name);
				for (int index = 0; index < items.length; index++) {
					System.out.println(items[index].getName() + ", " + items[index].getDesc());
				}
				System.out.println("Thanks you! Your wish fulfilled");
			}
		} while (selection != EXIT);
	}

	/**.
	* It's main method
	* @param args args
	*/
	public static void main(String[] args) {
		Input input = new ConsolInput();
		new StartUI(input).init();
	}
}
@@ -270,16 +270,100 @@
 input;%0A%0A
+%09/**.%0A%09* @tracker tracker its object for interaction%0A%09*/%0A%09private Tracker tracker;%0A%0A
 %09/**.%0A%09*
@@ -732,31 +732,24 @@
 election;%0A%09%09
-public 
 final int AD
@@ -753,31 +753,24 @@
  ADD = 0;%0A%09%09
-public 
 final int SH
@@ -778,31 +778,24 @@
 WALL = 1;%0A%09%09
-public 
 final int ED
@@ -800,31 +800,24 @@
 EDIT = 2;%0A%09%09
-public 
 final int DE
@@ -824,31 +824,24 @@
 LETE = 3;%0A%09%09
-public 
 final int FI
@@ -850,31 +850,24 @@
 BYID = 4;%0A%09%09
-public 
 final int FI
@@ -882,23 +882,16 @@
  = 5;%0A%09%09
-public 
 final in
@@ -3271,16 +3271,25 @@
 UI(input
+, tracker
 ).init()

add file for chapter_002_2.5.1