про такую процедуру слышала, но, как её применять, к сожалению, не знаю.
Прилагаю проект.
Прямо по процедурам сказать вряд ли что смогу, так как на Дельфи работаю не больше месяца, и программа не мной написана. Не подскажите, как тут можно организовать повторный запуск?
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form1.Hide;
form2.show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Tabs, Buttons, OleServer, StdCtrls,
ComCtrls, ExtCtrls, jpeg;
type
TForm2 = class(TForm)
Panel3: TPanel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Button1: TButton;
Label2: TLabel;
Button2: TButton;
Button3: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
ttst=record
ask:string;
one:string;
two:string;
three:string;
ans:integer;
subject:string;
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
const
max=5;
var
bal:integer;
TstWord,Tst:array[1..max] of ttst;
countY,countN:integer;
countT:integer;
indx:array[1..max]of integer;
mas:array[1..max]of string;
i:integer;
procedure CreateIndx; // задаем случайным образом вывод вопросов
var
rnd1,rnd2,i,z:integer;
begin
randomize;
for i:=1 to max do
Indx[i]:=i;
i:=1000000;
while 0<i do begin
rnd1:=random(max-1)+1;
rnd2:=random(max-1)+1;
z:=Indx[rnd1];
Indx[rnd1]:=Indx[rnd2];
Indx[rnd2]:=z;
dec(i);
end;
end;
procedure CreateTestWord;
begin
with TSTword[1] do begin
ask:='При растяжении';
one:='85';
two:='85,045';
three:='85,988';
ans:=1;
end;
with tstword[2] do begin
ask:='При растяжении в';
one:='85,00074879';
two:='85,04532314 ';
three:='85,09030112';
ans:=2;
end;
with tstword[3] do begin
ask:='При растяже';
one:='85,00074879';
two:='85,04532314 ';
three:='85,09030112';
ans:=3;
end;
with tstword[4] do begin
ask:='При растяжении волокн';
one:='85,00074879';
two:='85,04532314 ';
three:='85,09030112';
ans:=3;
end;
with tstword[5] do begin
ask:='При растяжении волокна с n';
one:='85,00074879';
two:='85,04532314 ';
three:='85,09030112';
ans:=3;
end;
end;
procedure PrintAsk(i:integer);
begin
with form2 do begin
Memo1.Text:='Задача: '+Tst[i].Ask;
RadioButton1.Caption:=Tst[i].one;
RadioButton2.Caption:=Tst[i].Two;
RadioButton3.Caption:=Tst[i].three;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
form2.Color:=rgb(236,233,216);
bal:=0;
CountY:=0;
CountN:=0;
CountT:=1;
i:=1;
CreateIndx;
CreateTestWord;
Tst:=TstWord;
PrintAsk(Indx[CountT]);
label2.caption:='Задача 1';
end;
procedure TForm2.Button1Click(Sender: TObject);
var
mark:string;
function FindMas(A:string):boolean;
var
k:integer;
begin
FindMas:=false;
for k:=1 to i do
if Mas[k]=A then begin
FindMas:=true;
break;
end;
end;
begin
with Tst[Indx[CountT]] do begin
if RadioButton1.Checked and (ans=1) then inc(CountY)
else if RadioButton2.Checked and (ans=2) then inc(CountY)
else if RadioButton3.Checked and (ans=3) then inc(CountY)
else begin
inc(CountN);
if not FindMas(subject) then begin
mas[i]:=subject;
inc(i);
end;
end;
label2.Caption:='Задача '+inttostr(CountT+1);
inc(CountT);
if countT=4 then begin
label2.Caption:='Задача 3';
button1.Enabled:=false;
bal:=1;
if CountY=3 then
begin
Button3.Show;
mark:='Отлично'; end
else if CountY>=2 then
begin
Button3.Show;
mark:='Хорошо';end
else if CountY>=1 then
begin
Button2.Show;
mark:='Удовлетворительно'; end
else begin mark:='Плохо! Решите правильно хотя бы 2 задачи';
Button2.Show;
bal:=0;
end;
showmessage('Правильно решено = '+inttostr(CountY)+#13+
'Неправильно решено = '+inttostr(CountN)+ #13+#13+
' Оценка: '+mark);
end else begin
RadioButton1.Checked:=false;
RadioButton2.Checked:=false;
RadioButton3.Checked:=false;
PrintAsk(Indx[CountT]); end;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.close;
form1.Show;
end;
end.
|