-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStation.java
More file actions
49 lines (41 loc) · 1.01 KB
/
Station.java
File metadata and controls
49 lines (41 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
import java.util.Observable;
public class Station extends Observable {
static String[] names= {"station_1","station_2","sation_3","station_4","station_5","station_6","station_7","station_8"};
static int[] times_out= {10,9,7,6,7,8,6,0};
static int[] times_enter= {0,4,6,5,4,4,5,7};
static int index = 0;
String name;
int time_enter,time_outside , time_until;
boolean pass=false;
TabTime tab;
public Station() {
this.time_until=getPredictionTime();
this.name=names[index];
this.time_outside=times_out[index];
this.time_enter=times_enter[index++];
}
private int getPredictionTime() {
int sum=0;
for (int i = 0; i < index-1; i++) {
sum+=times_out[i];
}
return sum;
}
public static int getIndex(String s) {
for (int i = 0; i < names.length; i++) {
if(names[i]==s) {
return i;
}
}
System.err.println("not found");
return 1;
}
@Override
public String toString() {
if(pass==true) {
return"{"+name+" , passing }";
}
else
return "{"+name+" ,not passing }";
}
}