1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
procedure TPrincipale.Button2Click(Sender: TObject);
var
F:TextFile;
s : array[1..6] of string;
i,j,h:byte;
somme:integer;
OK:integer;
stop:integer;
FileHandle:integer;
niv : byte;
label termine;
begin
stop:=0;
for h:=11 to 99 do begin
if (h<>10) and (h<>20) and (h<>30) and (h<>40) and (h<>50) and (h<>60) and (h<>70) and (h<>80) and (h<>90) and (h>10) then begin
if bouton[h].Caption = '' then stop:=stop+1;
if stop <> 0 then begin
ShowMessage('Vous n''avez pas terminée!!');
goto termine;
end
end;
end;
OK:=0;
for i:=1 to 9 do begin
Somme:=0;
for j:=1 to 9 do Somme := strtoint(bouton[Tableau[i,j]].Caption) + Somme;
if Somme<>45 then OK:=OK+1;
end;
for i:=1 to 9 do begin
Somme:=0;
for j:=1 to 9 do Somme := strtoint(bouton[Tableau[j,i]].Caption) + Somme;
if Somme<>45 then OK:=OK+1;
end;
for i:=1 to 9 do begin
Somme:=0;
for j:=1 to 9 do Somme:=strtoint(bouton[j+10*i].Caption)+Somme;
if Somme<>45 then OK:=OK+1;
end;
Timer1.Enabled:=false;
if OK=0 then begin
ShowMessage('Félicitation vous avez gagné en '+inttostr(temp-1)+' s!!');
if not FileExists(fichier) then begin
FileHandle :=FileCreate(fichier);
Fileclose(FileHandle);
Assignfile(F,fichier);
Rewrite(F);
for i:=1 to 6 do writeln(F,'0');
CloseFile(F);
end;
Assignfile(F,fichier);
Reset(F);
for i:=1 to 6 do Readln(F,s[i]);
CloseFile(F);
niv:=0;
if Dbutant1.Checked = true then niv:=1;
if Intermediaire1.Checked = true then niv:=2;
if Expert1.Checked = true then niv:=3;
case niv of
1 : if (s[2]='0') or ((s[2]<>'0') and (temp<strtoint(s[2]))) then begin
nom.visible:=true;
repeat
Application.HandleMessage;
until fin=2;
fin:=0;
s[1]:=nom.edit1.Text;
s[2]:=inttostr(temp);
Assignfile(F,fichier);
Reset(F);
Rewrite(F);
for i:=1 to 6 do writeln(F,s[i]);
CloseFile(F);
end;
2 : if (s[4]='0') or ((s[4]<>'0') and (temp<strtoint(s[4]))) then begin
nom.visible:=true;
repeat
Application.HandleMessage;
until fin=2;
fin:=0;
s[3]:=nom.edit1.Text;
s[4]:=inttostr(temp);
Assignfile(F,fichier);
Reset(F);
Rewrite(F);
for i:=1 to 6 do writeln(F,s[i]);
CloseFile(F);
end;
3 : if (s[6]='0') or ((s[6]<>'0') and (temp<strtoint(s[6]))) then begin
nom.visible:=true;
repeat
Application.HandleMessage;
until fin=2;
fin:=0;
s[5]:=nom.edit1.Text;
s[6]:=inttostr(temp);
Assignfile(F,fichier);
Reset(F);
Rewrite(F);
for i:=1 to 6 do writeln(F,s[i]);
CloseFile(F);
end;
end;
end
else ShowMessage('Vous avez perdu!!');
for i:=1 to 99 do begin
if (i<>10) and (i<>20) and (i<>30) and (i<>40) and (i<>50) and (i<>60) and (i<>70) and (i<>80) and (i<>90) and (i>10) then Bouton[i].Enabled:=false;
end;
termine:
end; |
Partager