让小车红灯停,绿灯行出现以下情况不能解决:
8 z/ I, W* y, B" e1)is' y9 t0 B- k6 A( |5 w
do! g' P9 p0 I4 N, a5 Y
if light="green"- B5 I+ a2 x1 \9 L. ~5 _! j
then @.stopped:=false;' W; v9 z$ R* O
else
$ f; y: n: f) J+ g O' b @.stopped:=true;( _+ f6 |( v, l( @8 `+ X
end;4 [7 s, u% ~+ E# T3 D. t' b. I, i
end;# t$ P u0 l1 u# s; _; }
- j( [2 h" U9 K* u. o: l
用if else then,只会停止,不能运动,停了以后Method 不会再被调;3 b6 g5 y' i: W% K Q7 c+ o: M- b
2)is
; X& v/ f) t, n$ t* }do
9 J) q* A2 L7 [. w% l if light="green"/ |/ ^1 I( }% l% n8 Z
then @.stopped:=false;
( B/ j! ^/ @1 n3 B# t" ?2 U/ U8 v else! N+ G/ m- R" _! X* l
@.stopped:=true;$ {7 d9 z4 S4 K T! A" G, ?' B
end;& I; u% x& G) p& P j* j% K0 x
@.move;--加了这个以后则不管红绿灯都是一直运动的,1 U5 {. t2 m+ l: a9 f! T7 [- Y, J
end;) i; P) \" l/ I" g/ f2 t/ Q
3)用ispect-when-when-else,出现同样的情况
; L+ k* F! r! }* x: K1 b求高手解决。 |