package com.inspect.guideline.calculate;

public class GuidelineCalculator {
    public static double calRdt(double weatherT, double currentT, double... difTs) {
        if (difTs != null && difTs.length != 0) {
            double difT = 0.0D;
            int count = 0;
            for (double dif : difTs) {
                ++count;
                difT += dif;
            }

            difT /= count;
            if (difT <= -1000.0D) {
                return 0.0D;
            } else {
                double dif0 = Math.abs(currentT - weatherT);
                double dif1 = currentT - difT;
                return (dif0 >= 30.0D || currentT >= 40.0D) && dif1 >= 0.0D ? dif1 / dif0 : 0.0D;
            }
        } else {
            return 0.0D;
        }
    }

    public static double calDt(double currentT, double... difTs) {
        if (difTs != null && difTs.length != 0) {
            int count = 0;
            double sum = 0.0D;
            for (double difT : difTs) {
                ++count;
                sum += Math.abs(currentT - difT);
            }

            return sum / (double) count;
        } else {
            return -1000.0D;
        }
    }
}
