让小车红灯停,绿灯行出现以下情况不能解决:
- T0 ^0 l6 |2 i0 m. l% u2 X! z1)is5 i3 R6 [+ m$ \
do
/ m+ i. R; N( t Y( _ if light="green"3 b) ~, F2 [+ Y( n1 C
then @.stopped:=false;
& g/ m! N+ \) f# y9 D# L& n" q7 v else5 ~2 f: T0 S" d( O6 t- z4 ~
@.stopped:=true;1 i/ P; u( t1 G8 m
end;
! N4 \7 L0 U/ n& A3 o3 O! a( V+ Lend;
/ _7 f5 b1 c# m: A0 {* h% ?4 T5 x/ D x; N* f8 |/ ]
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
, d3 f& n- f2 X# P) c: x2)is
: Z" y' u! T a9 O7 U6 fdo
% v+ j/ y! l# F" p- |- a" M9 q( B) u if light="green"
$ `6 p7 Q' r8 H# V then @.stopped:=false;
8 \: }( b- B$ B else
* C; ~' _) I2 ^ @.stopped:=true;
- f4 l8 ?6 R1 v+ W end;- v7 J9 n# R, z- s* S9 ?2 p9 b& Z7 u
@.move;--加了这个以后则不管红绿灯都是一直运动的,! o& W! i) b( {! c. N G( ^
end;* E* y1 D; o- S! `0 U y
3)用ispect-when-when-else,出现同样的情况& _; z8 F6 c8 P+ Y/ U
求高手解决。 |