让小车红灯停,绿灯行出现以下情况不能解决:9 K$ `4 z* x! C, q, a; w( Z( o2 P
1)is& l+ D0 P% h# X6 I( D
do0 G- K- L( N/ w$ R/ Y
if light="green"4 ` w; A* z9 `/ m. _! D W
then @.stopped:=false;
& f8 n+ {$ l8 n a7 \ else
2 w! e0 b! b$ E' ^! v- A! Z& e8 P @.stopped:=true;- c. H+ _* V( D) W1 n7 C
end;
) f) p$ g. y7 h2 F" d4 mend;
' [* x5 y3 e5 y9 J" H5 n
; e+ e% Q' ` {, }7 f" b用if else then,只会停止,不能运动,停了以后Method 不会再被调;* `3 N" l2 z4 q6 {7 B% f
2)is
1 Y+ w6 d( F A$ r% C" c* }do
5 Q, J3 V9 ]% S7 D' C if light="green" ?% ^& U& w4 M: V+ j
then @.stopped:=false;5 j$ Y+ m) h: e0 l
else* o. w% m- n3 b# h5 \6 a/ ^( I/ Y
@.stopped:=true;
4 s" V- a! h4 i' k# e, A- j5 n end;
$ f+ l# A& \. t& j- s. {@.move;--加了这个以后则不管红绿灯都是一直运动的,
. {5 Y/ B0 \: v' gend;
# x+ Q" S! m5 _3)用ispect-when-when-else,出现同样的情况+ E- u* G$ I, u5 X
求高手解决。 |