让小车红灯停,绿灯行出现以下情况不能解决:+ Z e3 X) ?1 ]' K; a
1)is6 ?) v! V3 `' |
do
. x" A* g/ Q2 F }1 B4 u if light="green"( D0 w$ U; v, v M& A$ }# P( P
then @.stopped:=false;
0 v2 Q' L% h2 W- x else0 _% }( g7 |2 j* M
@.stopped:=true;
. V5 f; Y' d, Y! ]. \ end;
- D( _& K& C. W& F0 oend;- E- x4 I4 }$ r( |6 l
5 c" _4 x# e' e3 ]
用if else then,只会停止,不能运动,停了以后Method 不会再被调;* T0 I/ V! Z/ F
2)is( l& `! \2 `; U
do
0 Y$ c3 y9 f3 d# _( q2 F2 w if light="green"7 p1 b s$ |9 _/ L
then @.stopped:=false;: b$ p6 T7 H, ^2 z
else
- e5 s- T4 Z1 V, ? @.stopped:=true; V! P3 S! M; j/ D$ T: O, i
end;
- [, u( F6 _( x- U: Q5 s8 h' f@.move;--加了这个以后则不管红绿灯都是一直运动的,* _3 c# _- y/ L2 h5 o4 m
end;
. _: T) x5 k3 S. f, _. y/ F3)用ispect-when-when-else,出现同样的情况
" S3 h* c* L. L求高手解决。 |