So I have a class called station and it holds a list of readings that holds temperature, windSpeed and pressure.
What would be the nicest way of getting min/max values of temperature, windSpeed and pressure?
This is how I have done it. But I don't know it feels wrong.
public static void setMinMaxValues(Station station) {
station.temperatureMin = station.windSpeedMin = station.pressureMin = Float.MAX_VALUE;
for (Reading reading : station.readings) {
if (station.temperatureMin > reading.temperature) station.temperatureMin = reading.temperature;
if (station.temperatureMax < reading.temperature) station.temperatureMax = reading.temperature;
if (station.windSpeedMin > reading.windSpeed) station.windSpeedMin = reading.windSpeed;
if (station.windSpeedMax < reading.windSpeed) station.windSpeedMax = reading.windSpeed;
if (station.pressureMin > reading.pressure) station.pressureMin = reading.pressure;
if (station.pressureMax < reading.pressure) station.pressureMax = reading.pressure;
}
}
I would appreciate any suggestions of how to improve it, or what could I look into to make it better.
improve it or make it better: Why? What's wrong with it?