让小车红灯停,绿灯行出现以下情况不能解决:* M; x- x. T4 H+ @; }# W/ |
1)is- j1 Y/ `" ~! c# X' J. G( k
do
: W- o& e8 N3 h8 v5 l! ~/ c: r; l if light="green"
Z1 G* A+ q# \% b7 F U then @.stopped:=false;) m& v' C$ K2 y3 E" M
else
# ^: [* S6 t3 X* R5 T @.stopped:=true;
0 F* K# O$ t3 }1 j; d0 Q end;8 {. L. g' m* K4 x q& }; f
end;
3 _9 V9 j1 O; i4 M/ s5 `
7 y: x, L* M' O3 j+ j, j( o$ x用if else then,只会停止,不能运动,停了以后Method 不会再被调;
7 U5 ]+ @$ c8 x- p2)is
" D4 T& P* X ~, z) V/ P9 hdo
* |; l) B" h3 Y; ]8 ]: F if light="green"* M; A7 o+ _% s |; t
then @.stopped:=false;
% s2 j* h1 }( W/ ? else& f% v' @) {" W! Y$ }4 G- |
@.stopped:=true;: ]7 j) R: J1 {" d
end;
9 {" x5 s9 V# a. A0 @# W. A' M@.move;--加了这个以后则不管红绿灯都是一直运动的,
5 ?! u$ a- }) Rend;- t. k. y6 [& h4 O$ z. T
3)用ispect-when-when-else,出现同样的情况
% ?$ G! ]' e+ b; \( Z/ r7 I求高手解决。 |