让小车红灯停,绿灯行出现以下情况不能解决:
. t# }7 p0 T9 O4 g% ]6 J1)is
8 E3 {0 ]/ H/ j/ d; Ddo0 T4 f) Z* o* q5 C, ~
if light="green"
1 y) v0 f( Q" B" ], l% g9 X/ i: | then @.stopped:=false;
" B& Q3 q: t3 I" B, r else
6 U) ]1 }" A% ^: O+ H( R x! W @.stopped:=true;
6 s; q- ?# _. i. p0 o end;
7 H" a s2 H& Wend;
5 W' w: Y* U+ d6 v; L, b0 Z! @0 g) W P/ h1 N
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
1 N$ }9 ?. j( {( `+ B) R2)is; ] Z. `7 l, D q# W& r
do
; a' T, |4 u3 K; A. x; } if light="green"7 h9 A' e( Z, ?% J+ H' \3 W. n
then @.stopped:=false;+ l+ f# k# B, P6 F
else# K: t; O* V3 x# a2 E8 ]
@.stopped:=true;
7 ?4 L7 {: N \8 s- D% {% d$ ]/ T end;
9 g2 N7 `( v. O1 H) _7 J@.move;--加了这个以后则不管红绿灯都是一直运动的,
1 V6 T0 O# r8 f/ A* vend;- X. E/ L0 t& m) @4 N V
3)用ispect-when-when-else,出现同样的情况
& y c. H) C3 \# ^2 R6 e2 O. Q4 e求高手解决。 |