<commit_before>package com.greensnow25.start;

import com.greensnow25.modules.Item;
import com.greensnow25.modules.Task;

/**
 * public class MenuTracker.
 * contein inner classes whos perfoms actions from then.
 *
 * @author greensnow 25.
 * @version 1.
 * @since 19.01.17.
 */
public class MenuTracker {

    /**
     * class object.
     */
    private Input input;
    /**
     * class object.
     */
    private Tracker tracker;
    /**
     * array of abjects.
     */
    private UserAction[] userActions = new UserAction[7];

    /**
     * array of keys from classes.
     */
    private int[] range = new int[userActions.length];

    /**
     * class constructor.
     *
     * @param input   class object.
     * @param tracker class object.
     */
    MenuTracker(Input input, Tracker tracker) {
        this.input = input;
        this.tracker = tracker;
    }

    /**
     * filling array objects with help inner clases.
     */
    public void filling() {
        userActions[0] = this.new AddItem("Add the item.", 0);
        userActions[1] = this.new FindById("Find item by id.", 1);
        userActions[2] = this.new ShowAll("Show items .", 2);
        userActions[3] = this.new UpdateItem("Edit item.", 3);
        userActions[4] = this.new DeleteItem("Delete item.", 4);
        userActions[5] = this.new FindByName("Find item by name: ", 5);
        userActions[6] = this.new AddComment("Add the comment", 6);
    }

    /**
     * method perfom actions with items.
     *
     * @param key action number.
     */
    public void select(int key) {
        this.userActions[key].execute(input, tracker);
    }

    /**
     * mehod write keys from classes in to array.
     */
    public void showkeys() {
        int position = 0;
        for (int index = 0; index < userActions.length; index++) {
            if (userActions[index] != null) {
                this.range[position++] = userActions[index].key();
            }
        }
    }

    /**
     * method collect informstiom from inner classes.
     */
    public void show() {
        for (UserAction useractions : userActions) {
            if (useractions != null) {
                System.out.println(useractions.info());
            }
        }
    }

    /**
     * Inner class AddItem.
     * add Item.
     */
    private class AddItem extends BaseAction {

        /**
         * constructor of class.
         *
         * @param name Information about what the class can do.
         */
        AddItem(String name, int keyAction) {
            super(name, keyAction);
        }

        @Override
        public void execute(Input input, Tracker tracker) {

            try {
                Item item = tracker.add(new Task(input.ask("name"), input.ask("desk")));
                item.getComments().addComent(input.ask("Enter new comment:"));
                System.out.println("operation sucsesfull ");

            } catch (ArrayIndexOutOfBoundsException e) {
                System.out.println("an array of filled application form please delete item");
            }<commit_msg>Update date 27.01.17<commit_after>package com.greensnow25.start;

import com.greensnow25.modules.Item;
import com.greensnow25.modules.Task;

/**
 * public class MenuTracker.
 * contein inner classes whos perfoms actions from then.
 *
 * @author greensnow 25.
 * @version 1.
 * @since 19.01.17.
 */
public class MenuTracker {

    /**
     * class object.
     */
    private Input input;
    /**
     * class object.
     */
    private Tracker tracker;
    /**
     * array of abjects.
     */
    private UserAction[] userActions = new UserAction[7];

    /**
     * array of keys from classes.
     */
    private int[] range = new int[userActions.length];

    /**
     * class constructor.
     *
     * @param input   class object.
     * @param tracker class object.
     */
    MenuTracker(Input input, Tracker tracker) {
        this.input = input;
        this.tracker = tracker;
    }

    /**
     * filling array objects with help inner clases.
     */
    public void filling() {
        userActions[0] = this.new AddItem("Add the item.", 0);
        userActions[1] = this.new FindById("Find item by id.", 1);
        userActions[2] = this.new ShowAll("Show items .", 2);
        userActions[3] = this.new UpdateItem("Edit item.", 3);
        userActions[4] = this.new DeleteItem("Delete item.", 4);
        userActions[5] = this.new FindByName("Find item by name: ", 5);
        userActions[6] = this.new AddComment("Add the comment", 6);
    }

    /**
     * method perfom actions with items.
     *
     * @param key action number.
     */
    public void select(int key) {
        this.userActions[key].execute(input, tracker);
    }

    /**
     * mehod write keys from classes in to array.
     */
    public void showkeys() {
        int position = 0;
        for (int index = 0; index < userActions.length; index++) {
            if (userActions[index] != null) {
                this.range[position++] = userActions[index].key();
            }
        }
    }

    /**
     * method collect informstiom from inner classes.
     */
    public void show() {
        for (UserAction useractions : userActions) {
            if (useractions != null) {
                System.out.println(useractions.info());
            }
        }
    }

    /**
     * Inner class AddItem.
     * add Item.
     */

    private class AddItem extends BaseAction {

        /**
         * constructor of class.
         *
         * @param name Information about what the class can do.
         */
        AddItem(String name, int keyAction) {
            super(name, keyAction);
        }

        @Override
        public void execute(Input input, Tracker tracker) {

            try {
                Item item = tracker.add(new Task(input.ask("name"), input.ask("desk")));
                item.getComments().addComent(input.ask("Enter new comment:"));
                System.out.println("operation sucsesfull ");

            } catch (ArrayIndexOutOfBoundsException e) {
                System.out.println("an array of filled application form please delete item");
            }
{'fraction_non_alphanumeric': 0.12167423750811161, 'fraction_numerical': 0.01135626216742375, 'mean_word_length': 1.883536014967259, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1696154', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1721, 'n_words': 482}