-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.java
More file actions
69 lines (58 loc) · 1.69 KB
/
Copy pathRoom.java
File metadata and controls
69 lines (58 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.adrianargint;
import java.util.ArrayList;
import java.util.Collections;
/**
* Class for a room which has devices for temperature, humidity and has area stored.
*/
public class Room {
private final String name;
private final Device deviceTemperature;
private final Device deviceHumidity;
private final int area;
public Room(String name, String deviceName, int area) {
this.name = name;
this.deviceTemperature = new Device(deviceName);
this.deviceHumidity = new Device(deviceName);
this.area = area;
}
public String getName() {
return name;
}
public Device getDeviceTemperature() {
return deviceTemperature;
}
public Device getDeviceHumidity() {
return deviceHumidity;
}
public int getArea() {
return area;
}
/**
*
* @return the minimum temperature value stored in the most recent interval
*/
public double minTemperature(){
for (int i = 0; i < 24; i++) {
ArrayList<Data> list = this.deviceTemperature.getList().get(i).getList();
if (list.size() != 0) {
Collections.sort(list);
return list.get(0).getValue();
}
}
return -1;
}
/**
*
* @return the maximum humidity value stored in the most recent interval
*/
public double maxHumidity(){
for (int i = 0; i < 24; i++) {
ArrayList<Data> list = this.deviceHumidity.getList().get(i).getList();
if (list.size() != 0) {
Collections.sort(list);
return list.get(list.size() - 1).getValue();
}
}
return -1;
}
}