File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ <h4 class="alert-heading">A new vehicle has joined the race!</h4>
61
61
// and add it to the list of marker
62
62
markers . push ( marker ) ;
63
63
64
- // tell the client that we have a new vehicle
64
+ // tell the user that we have a new vehicle
65
65
$ ( "#newVehicle" ) . removeClass ( "hide" ) ;
66
66
$ ( "#vehicleName" ) . text ( "And its name is \"" + move . id + "\" !" ) ;
67
67
window . setTimeout ( function ( ) {
Original file line number Diff line number Diff line change 7
7
import java .io .InputStream ;
8
8
import java .io .InputStreamReader ;
9
9
import java .util .ArrayList ;
10
+ import java .util .LinkedList ;
10
11
import java .util .List ;
12
+ import java .util .Queue ;
11
13
12
14
import org .apache .http .NameValuePair ;
13
15
import org .apache .http .client .HttpClient ;
@@ -32,21 +34,21 @@ public void simulateMovingVehicle() throws Exception {
32
34
int cpt = 0 ;
33
35
34
36
// we store the old location for the chaser vehicle
35
- List <String > cache = new ArrayList <String >();
37
+ Queue <String > queue = new LinkedList <String >();
36
38
37
39
String line ;
38
40
while ((line = br .readLine ()) != null ) {
39
41
String [] split = line .split (";" );
40
42
if (split .length > 1 ) {
41
43
42
- cache .add (line );
44
+ queue .add (line );
43
45
44
46
move ("Oh no, I'm being followed !!" , split );
45
47
46
48
// move the second vehicle ("the chaser")
47
49
// we let 20 steps ahead
48
50
if (cpt > 20 ) {
49
- String chaserPosition = cache . get ( cpt - 20 );
51
+ String chaserPosition = queue . poll ( );
50
52
move ("I'll catch you !!" , chaserPosition .split (";" ));
51
53
}
52
54
You can’t perform that action at this time.
0 commit comments