Skip to content

Commit e25b40d

Browse files
committed
Implement weather evaluators
1 parent 965deb3 commit e25b40d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Interfaces;
2+
using RealTimeWeatherMonitoringApp.Domain.Models;
3+
4+
namespace RealTimeWeatherMonitoringApp.Infrastructure.Evaluators;
5+
6+
public class WeatherHumidityEvaluator : IEvaluator<WeatherData>
7+
{
8+
private readonly double _threshold;
9+
private readonly Func<double, double, bool> _comparison;
10+
11+
public WeatherHumidityEvaluator(double threshold, Func<double, double, bool> comparison)
12+
{
13+
_threshold = threshold;
14+
_comparison = comparison;
15+
}
16+
17+
public bool Evaluate(WeatherData data) => _comparison(data.Humidity, _threshold);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Interfaces;
2+
using RealTimeWeatherMonitoringApp.Domain.Models;
3+
4+
namespace RealTimeWeatherMonitoringApp.Infrastructure.Evaluators;
5+
6+
public class WeatherTemperatureEvaluator : IEvaluator<WeatherData>
7+
{
8+
private readonly double _threshold;
9+
private readonly Func<double, double, bool> _comparison;
10+
11+
public WeatherTemperatureEvaluator(double threshold, Func<double, double, bool> comparison)
12+
{
13+
_threshold = threshold;
14+
_comparison = comparison;
15+
}
16+
17+
public bool Evaluate(WeatherData data) => _comparison(data.Temperature, _threshold);
18+
}

0 commit comments

Comments
 (0)