让小车红灯停,绿灯行出现以下情况不能解决:$ V- j7 i y; U3 {" n5 j! a( j
1)is9 X3 R3 }: o2 e$ \6 R* u) D
do
" X& e& q8 o: g# R if light="green"
$ ~! K3 j6 S3 L; }# | then @.stopped:=false;" {+ R6 _+ ] a I$ |3 g
else
, w9 s G6 d. ~/ C. \/ L8 @) ~ @.stopped:=true;
- I. x0 c( [2 Q; ~ end;
& d }4 w* f/ _) Eend;
+ c5 l& R; Z7 ^1 L9 y3 n3 A. I
0 `1 y& u: D* l9 |' {8 h用if else then,只会停止,不能运动,停了以后Method 不会再被调;
: Q" i/ V4 |6 x1 B6 t' X+ n2)is
4 K. |, E. s' o- m% z$ tdo+ s. o1 s" T+ | W: [8 t
if light="green"; ^# n$ H3 c0 o, v X
then @.stopped:=false;' S$ i% t2 g1 L! U
else
+ F9 S# ^7 l* m5 _0 L @.stopped:=true;# \0 z X4 w8 x# @5 I
end;( f% f: D( t% g. k' {# G
@.move;--加了这个以后则不管红绿灯都是一直运动的,
. ]9 M3 W5 e! a# Kend;5 [' o) q) k) y
3)用ispect-when-when-else,出现同样的情况4 X. V' V: e0 O% q
求高手解决。 |