<commit_before>package ru.job4j.lsp;

import java.util.TreeSet;

/**
 * Class for add food in correct storage.
 * @author agavrikov
 * @since 22.08.2017
 * @version 1
 */
public class ControlQuality {

    /**
     * Structure for storages.
     */
    private TreeSet<Storage> storages = new TreeSet<>();

    /**
     * Default constructor for initialisation storages.
     */
    public ControlQuality() {
        storages.add(new Warehouse(0, 25));
        storages.add(new Shop(25, 99));
        storages.add(new Trash(100, 100));
    }

    /**
     * Constructor for initialisation storages from param.
     * @param storages storages.
     */
    public ControlQuality(TreeSet<Storage> storages) {
        this.storages = storages;
    }


    /**
     * Method for put food in correct storage.
     * @param food food
     */
    public void putInStorage(Food food) {
        int percentExpiryFood = (int) (100 - (double) (food.getExpirydDate() - System.currentTimeMillis()) / (food.getExpirydDate() - food.getCreateDate()) * 100);
        if (percentExpiryFood > 100) {
            percentExpiryFood = 100;
        }
        if (percentExpiryFood > 75 && percentExpiryFood < 100) {
            food.setDiscount(50);
        }
        for (Storage storage : this.storages) {
            if (percentExpiryFood >= storage.getPercentExpiryControlFrom() && percentExpiryFood <= storage.getPercentExpiryControlTo()) {
                storage.putFood(food);
                break;
            }
        }
    }

    /**
     * Getter storages.
     * @return storages
     */
    public TreeSet<Storage> getStorages() {
        return this.storages;
    }
}<commit_msg>1. Динамическое перераспределение продуктов [#854]<commit_after>package ru.job4j.lsp;

import java.util.LinkedList;
import java.util.TreeSet;

/**
 * Class for add food in correct storage.
 * @author agavrikov
 * @since 22.08.2017
 * @version 1
 */
public class ControlQuality {

    /**
     * Structure for storages.
     */
    private TreeSet<Storage> storages = new TreeSet<>();

    /**
     * Default constructor for initialisation storages.
     */
    public ControlQuality() {
        storages.add(new Warehouse(0, 25));
        storages.add(new Shop(25, 99));
        storages.add(new Trash(100, 100));
    }

    /**
     * Constructor for initialisation storages from param.
     * @param storages storages.
     */
    public ControlQuality(TreeSet<Storage> storages) {
        this.storages = storages;
    }


    /**
     * Method for put food in correct storage.
     * @param food food
     */
    public void putInStorage(Food food) {
        int percentExpiryFood = (int) (100 - (double) (food.getExpirydDate() - System.currentTimeMillis()) / (food.getExpirydDate() - food.getCreateDate()) * 100);
        if (percentExpiryFood > 100) {
            percentExpiryFood = 100;
        }
        if (percentExpiryFood > 75 && percentExpiryFood < 100) {
            food.setDiscount(50);
        }
        for (Storage storage : this.storages) {
            if (percentExpiryFood >= storage.getPercentExpiryControlFrom() && percentExpiryFood <= storage.getPercentExpiryControlTo()) {
                storage.putFood(food);
                break;
            }
        }
    }

    /**
     * Method for resort food.
     */
    public void restore() {
        for (Storage storage : this.storages) {
            for (Food food : storage.getFoods()) {
                putInStorage(food);
            }
        }
    }

    /**
     * Getter storages.
     * @return storages
     */
    public TreeSet<Storage> getStorages() {
        return this.storages;
    }
}
{'fraction_non_alphanumeric': 0.11750205423171733, 'fraction_numerical': 0.024102985483429196, 'mean_word_length': 2.1240376390076987, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '12093', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1106, 'n_words': 248}