让小车红灯停,绿灯行出现以下情况不能解决:
/ w M$ k& `- x3 Z* Q) e1)is+ o }# \9 t8 E
do2 b2 H1 [- ~8 b8 V r2 R6 E7 z
if light="green"
# Y0 \7 O: @2 H4 C% q then @.stopped:=false;. c; H& U+ [9 S: p
else' U+ n* i* t; ^/ i8 j# }
@.stopped:=true;
! |6 Y8 _8 }; k: Y7 @( P end;
# f1 ?2 Y( J2 M9 @end;
) e; _( s; P# S! I/ x6 K4 U3 |- I9 C9 V" f6 e' u6 `
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
% l8 V1 _* V# b/ Z( T( F8 D2)is$ g& p, s3 m3 c6 D3 i8 E4 V
do/ z3 C: d/ R0 {
if light="green"
# n* s! N: K9 Y$ i then @.stopped:=false;
. |0 ^& m# w" A& J( f. ]! ` else
. G( e6 f: c$ S0 M+ h- T1 Z; r- [ @.stopped:=true;/ R/ _9 _- M! D- i
end;& V4 \$ f, w( G$ U! f9 v7 h
@.move;--加了这个以后则不管红绿灯都是一直运动的,, m7 X8 S' P8 J7 p5 V/ B: x
end;
4 J6 |3 m( I' p! L. `7 P3)用ispect-when-when-else,出现同样的情况
* l ^3 |) Z, f6 G- s( i求高手解决。 |