让小车红灯停,绿灯行出现以下情况不能解决:
8 X9 t$ ]! P+ S. `- j. V9 k1)is6 J/ R0 |* W6 h# c# t
do) I; Z z% |4 _+ k. W
if light="green"& o7 V8 O( n; M0 m8 h% y7 K
then @.stopped:=false;
6 G ~" @; m V& z; c else
( |# A5 c' h6 S: ]% V. c; x @.stopped:=true;. X+ V; M5 V( z: K# U# h9 n
end;4 P6 F/ D% v' h: \, u
end;9 L9 E/ _" a- P7 [4 y
3 K! n# E1 ]+ L9 T6 D( C# U2 ]. ?用if else then,只会停止,不能运动,停了以后Method 不会再被调;) l+ S- z4 l" g i, |
2)is/ v6 q" ?7 ^+ I+ r( N1 w% W. C# p( b( u
do
% r: `* s) o g7 l+ b if light="green"
" R5 S) C8 A8 J- _+ x) K then @.stopped:=false;$ \+ {# x1 S) a+ D9 p$ x
else+ L( p2 D. `0 h6 A$ ~
@.stopped:=true;
2 u, F7 j0 h5 c* A }# U end;
6 I( Z9 j, v1 g) o@.move;--加了这个以后则不管红绿灯都是一直运动的,, I5 `2 {) ]/ ^
end;
! w6 b) j) U/ @0 o3)用ispect-when-when-else,出现同样的情况
/ `. j0 U7 |4 k' D: J0 R! `( D求高手解决。 |