让小车红灯停,绿灯行出现以下情况不能解决:! @7 L$ O- M1 R
1)is9 e, U# }' j* I6 h6 e/ }- E8 m: |
do
% E7 Z! F1 f! j, w8 _ if light="green"
/ @" H% @9 S1 T# g+ H! _ then @.stopped:=false;
7 m( i5 M; i: Q4 t else t0 k) V) r5 e4 i8 l& t
@.stopped:=true;8 p' ~/ F# D4 x- m
end;
! G% ]+ N5 `: W+ Kend;
7 ~/ t' t- U% F3 ?1 K* J4 Z7 I( y5 X
用if else then,只会停止,不能运动,停了以后Method 不会再被调;; \, o' C8 }6 i% X' k6 N; S2 s
2)is9 d4 |8 z1 Z k- l- ^ t
do+ K2 q! t7 G# @! O
if light="green"' ]; ^( f1 f* B3 u5 g2 U
then @.stopped:=false;
# A( }& g2 a6 [, w, V: H' o- g ? else) J$ P9 h, \. ~
@.stopped:=true;
$ h' L7 `2 Z3 x end;- l) }2 B+ z. j) k) R
@.move;--加了这个以后则不管红绿灯都是一直运动的,4 |, W/ |$ N x8 H( G/ ?4 Y8 x7 `
end;* j I# \: [+ @; V% U# a
3)用ispect-when-when-else,出现同样的情况
: R- Z% S- K3 E) W求高手解决。 |