linkedin facebook linkedin facebook nod32

Delphida test dasturini yaratish usuli

Muallif: Mengliyev SH.

Qo`shilgan sana: 2014-10-20

Delphida test dasturini yaratish usuli

 

Dastur matni quyida berilgan.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls, OleCtrls, SHDocVw;

type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
LabeledEdit1: TLabeledEdit;
Memo1: TMemo;
SpeedButton3: TSpeedButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure LabeledEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FormActivate(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private

{ Private declarations }
public
{ Public declarations }
end;
type Test = record
Vopros,Otv1,otv2,otv3,otv4:string[150];
Nprotv:byte; end;
var
Form1: TForm1;
a: array of test;
b: array[0..54] of Byte;
k: Byte;
protv:integer;
s1,s2,s3:string;
Filenotfound:boolean = false;
implementation

{$R *.dfm}

Procedure UpdateTest(k:Byte);
begin
if Length(a)<k+1 then exit;
Form1.Label1.caption:=a[k].Vopros;
Form1.RadioButton1.Caption:=a[k].Otv1;
Form1.RadioButton2.Caption:=a[k].otv2;
Form1.RadioButton3.Caption:=a[k].otv3;
Form1.RadioButton4.Caption:=a[k].otv4;
case b[k] of
1: Form1.RadioButton1.Checked:=true;
2: Form1.RadioButton2.Checked:=true;
3: Form1.RadioButton3.Checked:=true;
4: Form1.RadioButton4.Checked:=true;
else begin
Form1.RadioButton1.Checked:=false;
Form1.RadioButton2.Checked:=false;
Form1.RadioButton3.Checked:=false;
Form1.RadioButton4.Checked:=false;
end;
end;//Case
end;

procedure TForm1.FormCreate(Sender: TObject);
label 1;
var t: test;
c:array of test;
i,l,n,m:Byte;
f: file of test;
y:integer;
f1:TEXTfILE;
ttt:longint;
begin
//
s1:=ExtractFilePath(Application.ExeName)+'Tests.dat';// test savol javonlari bilan
s2:=ExtractFilePath(Application.ExeName)+'Students.dat'; natija
s3:=ExtractFilePath(Application.ExeName);
randomize;
//
if not Fileexists(s1) then
if MessageDlg('Test fayli topilmadi!!! ',
mterror,[mbok],0)=mrok then begin filenotfound :=true; exit;end;

assignFile(f,s1);
reset(f);i:=0;
While not eof(f) do begin
i:=i+1;setlength(c,i);
read(f,c[i-1]);
end;closefile(f);

for l:= 1 to 55 do begin
1: n:=random(i);
if length(a)>0 then begin y:=0;
for m:=0 to length(a)-1 do if a[m].Vopros = c[n].Vopros then y:=y+1;
if y=0 then Begin Setlength(a,length(a)+1); a[Length(a)-1]:=c[n];end
else goto 1;
end else Begin Setlength(a,1); a[0]:=c[n] end
end;// For

for i:=0 to 54 do b[i]:=0;
k:=0;protv:=0;c:=nil;
UpdateTest(k);

ttt:=gettickcount div 500;
while (gettickcount div 500)< ttt+5 do;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
var i: byte;
begin
Speedbutton2.Enabled:=true;
if k=54 then speedbutton1.Glyph.LoadFromFile(s3+'comp.bmp');//comp.bmp test yuklanishidan oldin yuklanadigan rasm
if k<55 then begin k:=k+1 ;
UpdateTest(k);end else Begin
Label1.Visible:=false;
Radiobutton1.Visible:=false;
Radiobutton2.Visible:=false;
Radiobutton3.Visible:=false;
Radiobutton4.Visible:=false;
Speedbutton2.Visible:=false;
Speedbutton1.Visible:=False;
Labelededit1.Visible:=True;
SpeedButton3.Visible:=True;
For i:= 0 to 54 do
if a[i].Nprotv= b[i] then protv:=protv+1;
end;//if
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
b[k]:=1;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
B[k]:=2;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
b[k]:=3;
end;

procedure TForm1.RadioButton4Click(Sender: TObject);
begin
b[k]:=4;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
if k>0 then begin k:=k-1;
Updatetest(k);end else Speedbutton2.Enabled:=false;
end;

procedure TForm1.LabeledEdit1KeyPress(Sender: TObject; var Key: Char);
var g:TextFile;
begin
if key =#13 then Begin
assignFile(g,s2);append(g);
Writeln(g,Labelededit1.text+' '+inttostr(protv));
closefile(g);
Memo1.Lines.LoadFromFile(s2);
Memo1.Visible:=true;
end;// If
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
if filenotfound then form1.Close;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
close;
end;

end.

2176 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений