红绿灯(三)
做了三个圆代表三个灯,比之前的多一个灯,但用if语句一直不得法,现在终于成功了:我是先设定第一、二个灯为不可见,但不理解是不是顺序的问题而导致成功性。
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
a:boolean;
b:boolean;
begin
a:=true;
b:=false;
if shape1.visible=b and shape3.visible=a and shape2.visible=b then
begin
shape1.Visible:=a;
shape2.Visible:=b;
shape3.Visible:=b;
end
else if shape2.visible=b and shape1.visible=a and shape3.visible=b then
begin
shape1.Visible:=b;
shape2.Visible:=a;
shape3.Visible:=b;
end
else
begin
shape1.Visible:=b;
shape2.Visible:=b;
shape3.Visible:=a;
end;
end;
end.
页:
[1]