-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackSegment.java
More file actions
37 lines (33 loc) · 932 Bytes
/
TrackSegment.java
File metadata and controls
37 lines (33 loc) · 932 Bytes
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
package softlab;
import java.util.ArrayList;
public class TrackSegment {
private ArrayList<Vehicle> vehicles;
private TrackSegment neighboorField1;
private TrackSegment neighboorField2;
public TrackSegment() {
vehicles=new ArrayList<>();
}
public TrackSegment getNextSegment(Direction dir) {
System.out.println("The next segment was returned");
return neighboorField1;
}
public boolean checkCollide() {
if (vehicles.size()>1) {
System.out.println("Collision was detected");
return true;
}
else
{
System.out.println("Collision wasn't detected");
return false;
}
}
public void accept(Vehicle v) {
vehicles.add(v);
System.out.println(v.getClass().getSimpleName()+" was added to the trackSegment");
}
public void remove(Vehicle v) {
vehicles.remove(v);
System.out.println(v.getClass().getSimpleName()+" was deleted from the trackSegment");
}
}