-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStop.java
More file actions
63 lines (49 loc) · 1.35 KB
/
Stop.java
File metadata and controls
63 lines (49 loc) · 1.35 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
import java.util.*;
import java.lang.*;
public class Stop {
// contain queue of Riders waiting for bus
// instantiable for each bus stop
private Q1Gen<Rider>waitline; // queue of Riders waiting for bus
private String name;
private int number;
private Stat stopStat;
public Stop(String name, int number){
this.waitline = new Q1Gen<Rider>(); //general waitline
this.name = name;
this.number = number;
this.stopStat = new Stat();
}
// inspired by Washer2 class methods in washer simulation
public void enter(Rider r){
// adds a Rider to line of people waiting
waitline.add(r);
this.stopStat.updateQueueStats(BusSim.agenda.getCurrentTime(), this.getQLength());
}
public int getQLength(){
// returns number of people waiting in line, general line
return waitline.length();
}
public int getStopNumber(){
return number;
}
public String getName(){
return this.name;
}
public Rider remove(){
// remove a Rider from the queue
return (Rider) waitline.remove();
}
public Stat getStats(){
// returns all stats associated with this stop
return this.stopStat;
}
public void printStats(){
stopStat.displayStats();
}
public Q1Gen<Rider> getWaitline(){
return this.waitline;
}
public void setWaitline(Q1Gen<Rider> q1){
this.waitline = q1;
}
} //Stop class