让小车红灯停,绿灯行出现以下情况不能解决:6 |1 z! M& t( x$ O! _! R: o; T' u
1)is
; Z( X1 {4 e7 x. ?+ F9 pdo$ [6 v, |/ Z% w) s8 K y4 j1 b
if light="green"
( X3 ~' P, x' z! S9 u, t then @.stopped:=false;
& ?: `2 s# T; G0 N/ C else
* S7 M) Z0 B( m5 R) s0 b @.stopped:=true;
* Y( g; v# \6 c# q end;
+ |% ?# E9 ~, x+ K; V& i2 [' L# Uend;$ D+ T( R* t5 Z
0 H. G) z$ E% s' A4 w; ~# m
用if else then,只会停止,不能运动,停了以后Method 不会再被调;
" R J$ U( n6 W% h6 B6 z, @2)is8 W! _1 {6 v* i9 S4 u1 v) K
do& P2 z6 W) |1 I0 @; ]! |1 U
if light="green"$ Z& @6 @1 T& d
then @.stopped:=false;- |7 R" J8 B7 t$ Z
else/ Y; S9 s% `, N" ~
@.stopped:=true;' x& @# V' f3 _$ \
end;
& q# K! a$ {. G, L@.move;--加了这个以后则不管红绿灯都是一直运动的,
; V% u1 q4 P/ `/ Q7 Kend;
; S- @$ C1 J4 g5 `: V3)用ispect-when-when-else,出现同样的情况* s3 q8 V2 J; p( H1 P" r8 p( J( {; c
求高手解决。 |