-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeatherHubStorage.java
61 lines (51 loc) · 1.55 KB
/
WeatherHubStorage.java
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
public class WeatherHubStorage {
private String name;
private String location;
private double[][][][] storage = new double[1000][24][6][1];
public WeatherHubStorage(String pName, String pLocation) {
name = pName;
location = pLocation;
}
public void listData() {
// print all data in the storage array as long as the day is not null
for (int i = 0; i < storage.length; i++) {
if (storage[i][0][0][0] != 0) {
System.out.println("Day " + i);
for (int j = 0; j < 24; j++) {
for (int k = 0; k < 6; k++) {
System.out.println(storage[i][j][k][0]);
}
}
}
}
}
public void addData(double[][][][] data) {
// add the data to the storage array
for (int i = 0; i < 24; i++) {
for (int j = 0; j < 6; j++) {
storage[getDayFromData(data)][i][j][0] = data[getDayFromData(data)][i][j][0];
}
}
}
public int getDayFromData(double[][][][] data) {
double day = 0;
for (double i = 0; i < data.length; i++) {
if (data[(int) i][0][0][0] != 0) {
day = i;
}
}
return (int) day;
}
public double[][][][] getData() {
return storage;
}
public void setData(double[][][][] data) {
storage = data;
}
public String getName() {
return name;
}
public String getLocation() {
return location;
}
}