让小车红灯停,绿灯行出现以下情况不能解决:
8 c0 F/ i/ O& R8 }/ J% e1)is
) U6 m2 k3 {/ Q( `+ O4 Ldo8 Y* e5 X# a9 a" B4 O* C7 e4 w
if light="green"& M& R2 ~: l1 s) Q3 M% h( ]
then @.stopped:=false;0 W9 x7 P3 ]) r
else: m1 G( F" |+ c2 E' x* x4 U% R$ ?
@.stopped:=true;7 T7 H3 P( U8 w, L! \% Q3 M& j
end;8 Y6 c! T7 e2 S# j; t2 t. f
end;
8 o( v/ E' p9 ?6 q: a/ X/ ~& A7 h p4 `- t$ x8 [
用if else then,只会停止,不能运动,停了以后Method 不会再被调;" C' Q) P, f; v/ W; x: E$ i5 L6 W* F! A
2)is; Y2 U6 J% ~. \+ P
do) x) x- q( I9 z/ T6 ?" ?5 f7 p
if light="green"
: Z' w& r' Z4 C then @.stopped:=false;
( @6 \0 ] ?0 A( w2 M. |5 @3 N( T else) O6 q2 A6 b9 n
@.stopped:=true;2 `0 V- C* {( H3 s# o& a* r
end;
8 r8 q9 b- t, Y2 f; F& ]- V@.move;--加了这个以后则不管红绿灯都是一直运动的, o: |6 @% T9 F
end;
- |% z, o$ K4 Z9 V, t) S4 d' S" u6 k3)用ispect-when-when-else,出现同样的情况8 \. s8 F7 s @
求高手解决。 |