<commit_before>package ru.parsentev.task_004;

import org.slf4j.Logger;
import ru.parsentev.task_002.Point;
import ru.parsentev.task_003.Triangle;

import static org.slf4j.LoggerFactory.getLogger;

/**
 * TODO: comment
 *
 * @author parsentev
 * @since 28.07.2016
 */
public class IsoscelesTriangle extends Triangle {
    private static final Logger log = getLogger(IsoscelesTriangle.class);

    public IsoscelesTriangle(Point first, Point second, Point third) {
        super(first, second, third);
    }

    @Override
    public boolean exists() {
        boolean isExists = super.exists();
        if (isExists) {
            double firstSideLenght = Math.abs(first.distanceTo(second));
            double secondSideLenght = Math.abs(second.distanceTo(third));
            double thirdSideLenght = Math.abs(third.distanceTo(first));
            return firstSideLenght == secondSideLenght 
                    || secondSideLenght == thirdSideLenght 
                    || thirdSideLenght == firstSideLenght;
        }
        return isExists;
    }

    
}<commit_msg>#5 отдельный метод сравнения double<commit_after>package ru.parsentev.task_004;

import org.slf4j.Logger;
import ru.parsentev.task_002.Point;
import ru.parsentev.task_003.Triangle;

import static org.slf4j.LoggerFactory.getLogger;

/**
 * TODO: comment
 *
 * @author parsentev
 * @since 28.07.2016
 */
public class IsoscelesTriangle extends Triangle {

    private static final Logger log = getLogger(IsoscelesTriangle.class);
    private static final double EPSILON = 0.0001;

    public IsoscelesTriangle(Point first, Point second, Point third) {
        super(first, second, third);
    }

    @Override
    public boolean exists() {
        return super.exists() && isIsosceles();
    }

    private boolean isIsosceles() {
        double firstSideLenght = first.distanceTo(second);
        double secondSideLenght = second.distanceTo(third);
        double thirdSideLenght = third.distanceTo(first);
        return nearlyEqual(firstSideLenght, secondSideLenght, EPSILON)
                || nearlyEqual(secondSideLenght, thirdSideLenght, EPSILON)
                || nearlyEqual(thirdSideLenght, firstSideLenght, EPSILON);
    }

    public static boolean nearlyEqual(double a, double b, double epsilon) {
        final double absA = Math.abs(a);
        final double absB = Math.abs(b);
        final double diff = Math.abs(a - b);

        if (a == b) {
            return true;
        } else if (a == 0 || b == 0 || diff < Float.MIN_NORMAL) {
            return diff < (epsilon * Float.MIN_NORMAL);
        } else {
            return diff / Math.min((absA + absB), Float.MAX_VALUE) < epsilon;
        }
    }
}
{'fraction_non_alphanumeric': 0.10070605722779635, 'fraction_numerical': 0.017094017094017096, 'mean_word_length': 2.7755960729312763, 'pattern_counts': {'":': 0, '<': 6, '<?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': '371533', 'n_tokens_mistral': 869, 'n_tokens_neox': 814, 'n_words': 188}