让小车红灯停,绿灯行出现以下情况不能解决:5 U& l3 n, j# J8 F+ K+ k
1)is
8 w0 O7 d! E" I4 ado
6 L6 d4 ^5 L4 R4 @& `) y1 V0 Y if light="green"
- P0 ?9 V) x7 }; S# g then @.stopped:=false;
. {# J% P/ D* C0 n else! }: c+ i9 h a
@.stopped:=true;8 m, G. _4 q, p4 \% _
end;
2 s" n- {8 d/ _; W* Z4 y4 j+ jend;
* q# R/ H- \3 r# o5 H/ m I5 s) t
! q: o) t4 F$ X' l7 Z- R' {用if else then,只会停止,不能运动,停了以后Method 不会再被调;3 T5 Q6 y6 ~7 P' T, t& D
2)is' [0 x7 _* ]4 W5 W6 |
do& ^0 @( }1 T7 ~/ Y+ o' a2 D
if light="green"
4 {2 Z) p4 {$ D% h9 l8 R8 e( ?: V then @.stopped:=false;
) C. G$ a; X4 x/ y6 K* ~# J! s else1 e v( g$ O4 F- n J3 p
@.stopped:=true;
5 h6 d' }6 Z/ w6 A6 y* b end;, Z' L% L/ O! y
@.move;--加了这个以后则不管红绿灯都是一直运动的,6 K4 O9 K: Y, k! V& O
end;. ?* |7 M- ?" P3 p7 Z9 X
3)用ispect-when-when-else,出现同样的情况
+ u. _/ t/ S7 O" e5 M" h+ b求高手解决。 |