Код:
Код: Выделить всё
implementation
var s: boolean;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
s:=False;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
var Index, i, num: Integer; e: Boolean;
begin
if s then Exit;
s:=True;
for Index:= 0 to 4 do
if Sender=Controls[i] then break;
if not (Controls[Index] as TCheckBox).Checked
then (Controls[Index] as TCheckBox).Checked:=True
else
begin
num:=Index+1;
if Index=4 then num:= 0;
(Controls[num] as TCheckBox).Checked:=not (Controls[num] as TCheckBox).Checked;
num:=num+1; if Index=3 then num:=0;
(Controls[num] as TCheckBox).Checked :=not (Controls[num] as TCheckBox).Checked;
end;
e:=True;
for i:= 0 to 4 do
e:=e and (Controls[i] as TCheckBox).Checked;
if e then
for i:=0 to 4 do begin
(Controls[i] as TCheckBox).Caption:= 'Победа!';
(Controls[i] as TCheckBox).Enabled:=False;
end;
s:=False;
end;
end.