让小车红灯停,绿灯行出现以下情况不能解决:
0 T" T, @" ?" A' f- R8 q1)is
K# O% g: V0 ~2 G4 B: g$ udo
8 f; t4 Z' I: C# I# a9 A if light="green"* x5 }$ t4 t' J% t8 }& a; S
then @.stopped:=false;7 o5 Y. C: E8 Y8 f9 E9 v: g8 v; {
else) }$ r' W4 z4 \; G
@.stopped:=true;
6 o- i: M3 A2 ^8 L& c2 Q$ t end;( H+ M- d5 T& T* c2 c4 H
end;5 n8 @+ N. r, | d
0 T; R0 Q' }6 B5 T- x用if else then,只会停止,不能运动,停了以后Method 不会再被调;, Z. O5 N5 B) g- r& ]0 A1 Q
2)is
P+ ~4 C" s" E1 o% p) Z* Hdo5 W0 f& f' |5 Z! ]7 Z* l+ l8 E- [7 k
if light="green"( d. i6 n) K! {
then @.stopped:=false;3 s q/ Q J6 K% i! d& C
else9 x* E; C; h8 s x
@.stopped:=true;' @0 z% S( m6 l& B
end;( x0 y) C) U/ n' x& d
@.move;--加了这个以后则不管红绿灯都是一直运动的,
: o! U. r* c9 h* [3 t. Aend;, I& I8 Z7 r' P% ^4 P
3)用ispect-when-when-else,出现同样的情况2 P+ h. Y9 d- ~ ~6 s& @* L1 E
求高手解决。 |