让小车红灯停,绿灯行出现以下情况不能解决:9 Z4 X2 F5 f6 d. b
1)is
. K. W. d; T4 s' kdo
/ d* D4 i( C( h$ s0 G if light="green"
. P" N c. k4 E# n9 c then @.stopped:=false;
- U5 U- Y3 q: A% m- n7 N4 T& H/ r else
. I% r4 b' O/ u' W @.stopped:=true;0 h1 ]' d3 ]* T# m9 R; t1 E
end;, ~4 N! s+ w, W8 L
end;! U/ ?, a6 x+ I) e5 u
+ R ~/ K# D8 b0 ^用if else then,只会停止,不能运动,停了以后Method 不会再被调;4 v+ o5 y8 ?% I
2)is- ^: k! x% S# Q5 I5 v; e6 l
do5 n$ q5 N7 H0 B& P6 x
if light="green", f6 Y( d$ t- S' M5 d7 a2 k2 M* X+ s
then @.stopped:=false;
, n/ j- \- R4 Z, V) M, V1 B else
0 ]- m1 F, y) V1 X @.stopped:=true;; N* a/ M7 d1 h% y
end;8 C4 @6 t! ^, {& O; ]
@.move;--加了这个以后则不管红绿灯都是一直运动的,
6 u4 G7 W4 Z6 M# g+ B: ^9 dend;5 H, d" r% U7 p9 J9 y: H6 e
3)用ispect-when-when-else,出现同样的情况
H, t, N: O! b: h7 J' q3 R: D求高手解决。 |