让小车红灯停,绿灯行出现以下情况不能解决:5 x7 R1 y1 b* _, a {
1)is
- V' E+ N. ^. T5 W( m: [; Vdo
7 Y. ?( k7 Y3 u) H: D" s& M if light="green"
4 m7 A3 ^* Y* W( U then @.stopped:=false;
/ o0 M4 @ D: } else% Y' f: W6 |# m
@.stopped:=true;
8 a4 [, o, f% w# f t4 D0 @ end;! ^$ t- L7 z6 E8 [/ x7 [
end;4 i! w8 Z9 g: i9 W% I2 @4 F+ X
$ M4 |. k) e; p8 [ N4 K用if else then,只会停止,不能运动,停了以后Method 不会再被调;9 {& R0 O& }+ N! o4 Z
2)is% O2 U& b8 C! R' B
do
8 m. o0 N( A2 J e. u if light="green"! ?5 H" c) W+ }% m
then @.stopped:=false;
* K' X! H2 Y/ v8 w% a m9 \ else' q" F$ u) s' H+ G# Y9 h9 Y
@.stopped:=true;
$ ?# |5 u6 c: o, `% g3 h& }1 f end;
+ J6 x- X" J' b" j$ r; ~@.move;--加了这个以后则不管红绿灯都是一直运动的," m5 t4 P8 \* e* J
end;! f$ i7 E( D8 z4 p
3)用ispect-when-when-else,出现同样的情况
, B8 B: C' \9 n/ J2 G4 x求高手解决。 |