A simple guessing game for amatuer programmers like myself.

unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
  StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1;
  x: integer;
  guessnumber: integer;
  myrandomnumber: integer;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin

randomize;
myrandomnumber:= integer(random(20)+1);
label1.caption:= inttostr (myrandomnumber);
edit1.text:= inttostr(5);
guessnumber:= 5;
edit2.text:= ' ';
label1.visible:= false;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin

label1.caption:= inttostr(myrandomnumber);
if
label1.visible= true
then
label1.visible:= false
else
label1.visible:= true;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin

guessnumber:= guessnumber -1;
edit1.text:= inttostr (guessnumber);
if
guessnumber= 0 then
form1.close
else
if
(strtoint(edit2.text)= myrandomnumber)
then
label2.caption:=  'Well Done'
else
if
(strtoint(edit2.text)< myrandomnumber)
then
label2.caption:= 'Number Too Low'
else
label2.caption:='Number Too High'


end;

initialization
  {$I unit1.lrs}

end.