public static bool BiggerEqual(string value, string threshold) { if (!checkTemperatureFormat(value) || !checkTemperatureFormat(threshold)) { return(false); } return(Convert.ToDouble(TemperatureComparer.ToCelsius(value)) >= Convert.ToDouble(TemperatureComparer.ToCelsius(threshold))); }
public static bool LessEqual(string value, string threshold, string range) { if (!checkTemperatureFormat(value) || !checkTemperatureFormat(threshold) || failToPassTemperatureFormat(range)) { return(false); } var valueInCelsius = Convert.ToDouble(TemperatureComparer.ToCelsius(value)); var thresholdInCelsius = Convert.ToDouble(TemperatureComparer.ToCelsius(threshold)); // ignore +/-, or +, or - three possible options right now. var rangeTemeprature = range.Split(' ')[1] + " " + range.Split(' ')[2]; var rangeInCelsius = Convert.ToDouble(TemperatureComparer.ToCelsius(rangeTemeprature)); return(Math.Abs(valueInCelsius - thresholdInCelsius) <= Math.Abs(rangeInCelsius)); }
public override bool CheckInRange(string temperature, string threshold, string range) { return(TemperatureComparer.LessEqual(temperature, threshold, range)); }
public override bool PassThreshold(string temperature) { return(TemperatureComparer.LessEqual(temperature, ThresholdValue)); }