-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBusStop.java
More file actions
47 lines (41 loc) · 1.03 KB
/
BusStop.java
File metadata and controls
47 lines (41 loc) · 1.03 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
//Create the BusStop subclass
import java.util.ArrayList;
import java.io.IOException;
import java.io.OutputStream;
public class BusStop extends Location {
/**
*
*/
private static final long serialVersionUID = 10;
protected ArrayList <Line> line;
public BusStop () {
super ();
line = new ArrayList <Line> ();
}
public BusStop (String n, int x, int y) {
super (n, x, y);
line = new ArrayList <Line> ();
}
public BusStop (String n, int x, int y, Line [] l, int length) {
super (n, x, y);
line = new ArrayList <Line> (length);
for (int i = 0; i < l.length; i ++) {
line.add(l[i]);
}
}
public void addLine (Line l) {
line.add (l);
}
public void printLineInfo (OutputStream o) throws IOException {
o.write (getLineInfo().getBytes());
}
public String getLineInfo () {
String s = super.toString () + "\n";
s += "Following lines stop at this bus stop: " + "\n";
for (int i = 0; i < line.size () - 1; i ++) {
s += line.get(i).name + ", ";
}
s += line.get(line.size () - 1).name + "\n";
return s;
}
}