unit Str;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;

    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  i,j:integer;
  s,s1:string;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
  randomize;
  edit1.text:='';edit2.text:='';
  s:='';s1:='';
  for i:=1 to 5 do begin
    s1:=inttostr(random(9)+1);
    s:=s+s1;
  end;
  edit1.Text:=s;
  edit1.Visible:=true;
  timer1.Interval:=2000;
  timer1.enabled:=true;
  edit2.Visible:=false;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  edit1.Visible:=false;
  edit2.Visible:=true;
  form1.ActiveControl:=edit2;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  timer1.Enabled:=false;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then begin
    s1:=edit2.Text;
    if s1=s then begin
       showmessage(' Правильно ');
       edit2.Text:='';
    end;
    if s<>s1 then begin
      showmessage(' Неправильно ! Верный ответ = '+s);
    end;
    edit1.Visible:=true;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  halt;
end;

end.
