
Розробка програми «тест по фізиці»
Постановка задачі
Розробити проект для тестування з використанням режиму редагування та режиму тестування, передбачити використання графіки, застосування файлів, записування результатів тестування.
Лістинг програми
unit Unit2;interface
use
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons,StdCtrls, Buttons, Controls, Classes;
type TForm2 = class(TForm) ListBox1: TListBox;
ListBox2: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
BitBtn1: TBitBtn;
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Implementation
{$R *.dfm}
procedure TForm2.ListBox1Click(Sender: TObject);
begin
If key=#13 then Num1:=ListBox1.ItemIndex;
end;
procedure TForm2.ListBox2Click(Sender: TObject);
begin
If key=#13 then begin
case ListBox2.ItemIndex of
0: Num2:= 2;
1: Num2:= 1;
2: Num2:= 3;
3: Num2:= 0;
end;
if Num1=Num2 then
begin
Label4.Caption:='Правильно';
CountR:=CountR+1
End
Else Label4.Caption:= 'Помилка';
If CountR=5 then
ShowMessage(‘ Тест закінчений! ‘ );
end.
StdCtrls, Buttons, Controls, Classes;
type
TForm2 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
BitBtn1: TBitBtn;
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Implementation
{$R *.dfm}
procedure TForm2.ListBox1Click(Sender: TObject);
begin
If key=#13 then Num1:=ListBox1.ItemIndex;
end;
procedure TForm2.ListBox2Click(Sender: TObject);
begin
If key=#13 then begin
case ListBox2.ItemIndex of
0: Num2:= 2;
1: Num2:= 1;
2: Num2:= 3;
3: Num2:= 0;
end;
if Num1=Num2 then
begin
Label4.Caption:='Правильно';
CountR:=CountR+1
End
Else Label4.Caption:= 'Помилка';
If CountR=5 then
ShowMessage(‘ Тест закінчений! ‘ );
end.