-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosAvg.java
More file actions
55 lines (40 loc) · 1.01 KB
/
PosAvg.java
File metadata and controls
55 lines (40 loc) · 1.01 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
import java.io.IOException;
public class PosAvg extends MesoInherit{
private String stID;
private Object stationMinus1;
private Object stationMinus2;
private Object stationPlus1;
private Object stationPlus2;
public PosAvg(String stID) throws IOException {
this.stID = stID;
readStations();
// TODO Auto-generated constructor stub
}
public int indexOfStation() {
int index = 0;
for(int i = 0; i < list.size(); ++i) {
if(stID.equals(list.get(i)))
{
index = i;
}
}
otherStations(index);
return index;
}
public void otherStations(int index)
{
if (index > 1 && index < 120)
{
this.stationMinus1 = list.get(index - 1);
this.stationMinus2 = list.get(index - 2);
this.stationPlus1 = list.get(index + 1);
this.stationPlus2 = list.get(index + 2);
}
}
public String toString() {
indexOfStation();
return String.format("This index is average of %s and %s, %s and %s, and so on.", stationMinus1,
stationPlus1, stationMinus2 ,
stationPlus2);
}
}