让小车红灯停,绿灯行出现以下情况不能解决:+ s9 ?0 p2 g) [, J: Y' i \! v
1)is3 l& b; |. g. j" y
do0 j: l4 `: ]. ]6 K) y6 U, W
if light="green"
$ [$ M! X. S9 B# t8 g; ]* w5 v then @.stopped:=false;6 T- y$ ]6 @+ @( m1 M
else4 h. o# _/ L9 m8 A
@.stopped:=true;
1 F) [3 K O4 s% i4 J r! H end;
9 X3 @' X" S% r# P5 Qend;
2 w! d* x; b- ]. q
3 D: R N; D. t& [* V/ N用if else then,只会停止,不能运动,停了以后Method 不会再被调;7 E) v/ w7 l. O' D1 x0 [3 Z5 M8 d
2)is
0 \' {( R8 i5 H- r( Odo
' V+ u1 t( f' L9 {1 [ if light="green"1 O3 H" O; g3 U) ~
then @.stopped:=false;+ j$ g! a9 P0 H9 ~' y0 c/ [
else
, I) l& j' A+ Z2 @1 R& d" j7 W @.stopped:=true;
' c, ]7 U9 V' v) g! k end;/ Z1 i2 x1 a) D
@.move;--加了这个以后则不管红绿灯都是一直运动的,! Y2 T; e* i# w# P- g4 W! X5 [
end;* a( s4 s- S8 D. k) w# `
3)用ispect-when-when-else,出现同样的情况
. s5 u+ o9 A2 M$ D& ^求高手解决。 |