让小车红灯停,绿灯行出现以下情况不能解决:
9 t! c! _- U# }) o1)is. F& O# Z; l2 a7 M
do1 o4 q9 T/ s0 b- N
if light="green"+ @$ ^+ U0 X; U5 \
then @.stopped:=false;% {% K8 B# Y. F5 D
else
$ L" T* Q& ^+ P. n! A @.stopped:=true;' V# a0 ]! |- M8 l* y6 U( Y& s
end;8 n; c- u/ q4 Y0 u
end;4 A( O# W7 k) ?+ C; m$ t) z1 _
: o* s r; S# g" l8 }) d: W z
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
2 `" L/ l3 c) `+ @7 m7 E+ u, Y2)is
$ r- Z8 o1 d3 Jdo% T9 f* P9 L! \, T/ I4 v0 p
if light="green": n8 ~/ e0 |. @! Q; o
then @.stopped:=false;; A- s- }" \ G2 _' M1 d/ ^( w
else0 A7 x, B. h7 E: i/ V2 O# [. Y
@.stopped:=true;
" Y8 |1 t$ e8 l- A+ H d# _) T end;
7 ?! T- K9 x& O- ^3 I@.move;--加了这个以后则不管红绿灯都是一直运动的,) P! J& V, N0 K7 n3 q2 Y6 N* x
end;
8 f" i5 X$ l" v6 z0 p1 s2 U3)用ispect-when-when-else,出现同样的情况5 T, G0 f, \$ g
求高手解决。 |