package fr.uge.concurrence;

import java.util.ArrayList;
import java.util.List;

import com.domo.Heat4J;

public class Application {
	public static void main(String[] args) {
		var rooms = List.of("bedroom1", "bedroom2", "kitchen", "dining-room", "bathroom", "toilets");

		var temperatures = new ArrayList<Integer>();

		for (var room : rooms) {
			try{
				var temperature = Heat4J.retrieveTemperature(room);
				IO.println("Temperature in room " + room + " : " + temperature);
				temperatures.add(temperature);
     		} catch (InterruptedException e) {
        		throw new AssertionError(e);
      		}
		}

		IO.println(temperatures.stream().mapToInt(Integer::intValue).average().getAsDouble());
	}
}
