让小车红灯停,绿灯行出现以下情况不能解决:
& a9 F8 f; Y1 r1)is# u5 x1 I( F0 S) Z7 Z+ V- d
do. z8 C# f# h# U9 ~/ {8 G
if light="green"/ P. v6 I2 Y& i) F k
then @.stopped:=false;
: ~# H4 _1 U1 t: J) {/ V else$ |1 q' u& d% [
@.stopped:=true;) B5 ?0 c9 O- Y q' q3 I6 R
end;
) L1 x7 s8 T, x0 n h( B2 O2 qend;3 Q) z' n( N6 b( I* S3 ~! |
! U( Y' E# P$ Y
用if else then,只会停止,不能运动,停了以后Method 不会再被调;1 e+ g: C' a; S# U! S
2)is
8 d4 `8 v1 O6 ldo$ r# e' k* w' O- K
if light="green"* B i, L: t2 N) h
then @.stopped:=false;+ `1 n& P4 \" t
else
. p9 [0 H* X- |4 n/ Q7 C% y @.stopped:=true;; u3 N7 s/ f4 U4 i$ d
end;
' T4 h6 @* w2 b/ _- Z* s4 U5 g@.move;--加了这个以后则不管红绿灯都是一直运动的,3 z2 s# J9 |( a( H+ P& k, C
end;# C# I. s* ?% ~5 ^6 @0 N
3)用ispect-when-when-else,出现同样的情况# o: t8 r$ T, f: l; Y: ~ J' `
求高手解决。 |