unit Raten4;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl, Oben, Unten: Integer;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
    Unten := Zahl;
    Zahl  := (Oben+Zahl) div 2;
    Label1.Caption := IntToStr(Zahl);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Label1.Caption := IntToStr (Zahl);
  Label2.Caption := 'Klick, ob zu klein oder zu groß';
  Button1.Visible := true;
  Button3.Visible := true;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Oben := Zahl;
  Zahl := (Unten+Zahl) div 2;
  Label1.Caption := IntToStr (Zahl);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Unten := 0;
  Oben  := 10000;
  Zahl  := (Oben+Unten) div 2;
  Button1.Visible := false;
  Button3.Visible := false;
end;

end.
