让小车红灯停,绿灯行出现以下情况不能解决:5 t# J7 R* i" E4 X: _/ Z' @
1)is, }4 T4 @1 ~6 o
do
6 Q( F5 ~# i5 n6 F' @ if light="green"6 N( s; M* W7 V* P8 F
then @.stopped:=false;& y2 \$ f9 A* p: n# t
else
0 E0 S9 R! f, M* @% Q @.stopped:=true;* T$ J+ \8 x$ e" t, F
end;0 ~7 O- ^& d) x0 R* \1 d
end;1 e% B! C& K" t! X0 l/ L
; D* |% Y% f: b* c5 l' x用if else then,只会停止,不能运动,停了以后Method 不会再被调;; X- R6 v! g0 K: D" A3 ~
2)is
, Z: s* I' m f6 l$ |do
5 h& u# _& s* g* h$ Q if light="green"
2 s8 U- z& }' |2 M& ~$ T' | then @.stopped:=false;
& v/ l& l9 C/ U ~6 i else
" ]* r" l8 }' I# c9 b @.stopped:=true;
0 T0 X! u8 W t* U" t' e. { end;' j; k# V, H4 `. P
@.move;--加了这个以后则不管红绿灯都是一直运动的,
. S, \) ~, l- x1 r# cend;
7 I0 m. c) s' m" F; n" ?" M- R, E3)用ispect-when-when-else,出现同样的情况
' m: e0 d$ g6 _( u8 Z求高手解决。 |