unit Test_mat;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Menus;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    ListBox1: TListBox;
    ListBox2: TListBox;
    BitBtn1: TBitBtn;
    Label5: TLabel;
    Label3: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure ListBox1KeyPress(Sender: TObject; var Key: Char);
    procedure ListBox2KeyPress(Sender: TObject; var Key: Char);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Num1, Num2, CountR,rez:integer;

implementation

{$R *.dfm}

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

procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: Char);
begin
If key=#13 then
Num1:=ListBox1.ItemIndex;
Form1.ListBox1.Enabled:=false;
Form1.ListBox2.Enabled:=True;
Form1.ActiveControl:=ListBox2;
end;

procedure TForm1.ListBox2KeyPress(Sender: TObject; var Key: Char);
begin
If key=#13 then begin
  case ListBox2.ItemIndex of
    0:Num2:=0;
    1:Num2:=1;
    2:Num2:=2;
    3:Num2:=3;
    4:Num2:= 4 ;
    5:Num2:= 5  ;
    6:Num2:= 6  ;
    7:Num2:=  7 ;
    8: Num2:=8;
    9: Num2:=9;
end;
if Num1=Num2 then
  begin
    Label5.Caption:='Верно';
    rez:=rez+1;
    Form1.ListBox2.Enabled:=false;
    Form1.ListBox1.Enabled:=true;
    Form1.ActiveControl:=ListBox1;
    end
    Else begin
       Label5.Caption:='Ошибка';
       Form1.ListBox2.Enabled:=false;
       Form1.ListBox1.Enabled:=true;
       Form1.ActiveControl:=ListBox1;
    end;
 CountR:=CountR+1;
 Form1.ListBox1.Items.Delete(Num1);
 Form1.ListBox1.Items.Insert(Num1,'');
 Form1.ListBox2.Items.Delete(Num2);
 Form1.ListBox2.Items.Insert(Num2,'');
 if CountR=10 then ShowMessage('Тест окончен Оценка: '+IntToStr(rez div 2+ord(rez div 2<1))+'(Правильных ответов'+IntToStr(rez)+')');
end;
end;



end.


