让小车红灯停,绿灯行出现以下情况不能解决:; M( J. d( @; V& h. Z1 T' h* J( L7 Y
1)is
4 W+ X, C" |6 h: e& q( F8 P2 wdo0 l+ g6 I% @3 A/ v1 g
if light="green"7 \- a# D# O) [1 x8 i3 f
then @.stopped:=false;% [9 g, I2 u/ x6 j# _
else
( ^( Y& P0 W' T: H& u# x3 E @.stopped:=true;
1 l2 A. P P. z# M end;" l* n+ j, H& x- e7 @% K( N4 d
end;) P& ]' M" V, Z2 {& }
6 J" r" a- t: M+ e/ i用if else then,只会停止,不能运动,停了以后Method 不会再被调;
x |8 s. I9 Y( E" b. c, [, j7 M2)is
( n- M+ N3 V" Q- vdo
$ {3 Q; s5 K {2 h9 V: X9 e6 | if light="green"
* p+ O: ]# f$ [* t2 I then @.stopped:=false;
! k! k; @" m( Z" p1 ] else2 d' H0 @. E# A& L# U, w; Y) O
@.stopped:=true; d n: k9 F& o3 q9 `1 d6 z! [) w
end;3 a7 d. e2 G+ g1 l8 Z4 T( \2 ]
@.move;--加了这个以后则不管红绿灯都是一直运动的,
+ X! \. R6 {1 ?& f7 {end;! n' I% L' Z# P& x n3 y6 E' u
3)用ispect-when-when-else,出现同样的情况: ~" l+ Z4 \5 e, P$ F
求高手解决。 |