unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    BitBtn1: TBitBtn;
    ListBox1: TListBox;
    ListBox2: TListBox;
    Label6: TLabel;
    procedure ListBox2KeyPress(Sender: TObject; var Key: Char);
    procedure ListBox1KeyPress(Sender: TObject; var Key: Char);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  num1,num2,countr,rez:longint;
implementation

{$R *.dfm}

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

    end;
 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
            Label4.Caption:='Правильно';
             rez:=rez+1;
            Form1.ListBox2.Enabled:=false;
             Form1.ListBox1.Enabled:=true;
            Form1.ActiveControl:=ListBox1;
          end
          else begin
             Label4.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;

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

end.
