让小车红灯停,绿灯行出现以下情况不能解决:! J; E# M( X3 H+ y
1)is
0 G8 h; R% U w' B7 c' cdo
* O5 M5 {6 D0 B if light="green"
4 g* T' {$ B4 l+ G* g( j then @.stopped:=false;
* M0 `; {7 r. D2 U1 ~ else
) |/ k+ f8 i4 q. V @.stopped:=true;4 j0 y" b, v! `8 N9 ^
end;
, X5 ~$ O3 |) k& Q0 S& ]end;5 {5 P( c" Z5 S# N9 s5 {
( ]4 ?1 A$ f/ m, Q) H' A
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
0 g9 @* I- ]& B- u. B2)is
# @2 e3 K9 |& J" h% h( m8 Edo' @# E0 \! t0 c7 R; ~2 z
if light="green"9 J8 m- A5 N$ S9 I8 p+ Z2 Q
then @.stopped:=false;: x& @6 j4 k" I& W) o6 t9 d; e
else: q$ C* o* U3 E
@.stopped:=true;
1 j$ b. ^2 U: X4 c, v, r7 s- ^" N end; b4 m4 x% i' g5 E
@.move;--加了这个以后则不管红绿灯都是一直运动的,
* C6 n+ `+ a/ }( W$ w" y) rend;
) }. X9 u* K8 Y* S W' P3)用ispect-when-when-else,出现同样的情况+ d5 J/ |3 {& O
求高手解决。 |