unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ButtonWithColor;

type
  TForm1 = class(TForm)
    Name1: TBitBtnWithColor;
    Name2: TBitBtnWithColor;
    Name3: TBitBtnWithColor;
    Name4: TBitBtnWithColor;
    Body1: TBitBtnWithColor;
    Body2: TBitBtnWithColor;
    Body3: TBitBtnWithColor;
    Body4: TBitBtnWithColor;
    Plus1: TBitBtnWithColor;
    Plus2: TBitBtnWithColor;
    Plus10: TBitBtnWithColor;
    Plus20: TBitBtnWithColor;
    Back: TBitBtnWithColor;
    Reset: TBitBtnWithColor;
    procedure Name1Click(Sender: TObject);
    procedure Name2Click(Sender: TObject);
    procedure Name3Click(Sender: TObject);
    procedure Name4Click(Sender: TObject);
    procedure Name1KeyPress(Sender: TObject; var Key: Char);
    procedure Name2KeyPress(Sender: TObject; var Key: Char);
    procedure Name3KeyPress(Sender: TObject; var Key: Char);
    procedure Plus1Click(Sender: TObject);
    procedure Plus2Click(Sender: TObject);
    procedure Plus10Click(Sender: TObject);
    procedure Plus20Click(Sender: TObject);
    procedure Name4KeyPress(Sender: TObject; var Key: Char);
    procedure ResetClick(Sender: TObject);
    procedure BackClick(Sender: TObject);



  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  stisk, back_kolik, back_kde:word;

implementation

{$R *.dfm}

procedure TForm1.Name1Click(Sender: TObject);
begin
stisk := 1;
name1.font.Color:=clFuchsia;
name2.font.Color:=clLime;
name3.font.Color:=clLime;
name4.font.Color:=clLime;

end;

procedure TForm1.Name2Click(Sender: TObject);
begin
stisk := 2;
name1.font.Color:=clLime;
name2.font.Color:=clFuchsia;
name3.font.Color:=clLime;
name4.font.Color:=clLime;
end;

procedure TForm1.Name3Click(Sender: TObject);
begin
stisk := 3;
name1.font.Color:=clLime;
name2.font.Color:=clLime;
name3.font.Color:=clFuchsia;
name4.font.Color:=clLime;
end;

procedure TForm1.Name4Click(Sender: TObject);
begin
stisk := 4;
name1.font.Color:=clLime;
name2.font.Color:=clLime;
name3.font.Color:=clLime;
name4.font.Color:=clFuchsia;
end;

procedure TForm1.Name1KeyPress(Sender: TObject; var Key: Char);
begin
if ord(key) = 8 then name1.Caption:=''
                else name1.Caption:=name1.Caption+key;
end;

procedure TForm1.Name2KeyPress(Sender: TObject; var Key: Char);
begin
if ord(key) = 8 then name2.Caption:=''
                else name2.Caption:=name2.Caption+key;
end;

procedure TForm1.Name3KeyPress(Sender: TObject; var Key: Char);
begin
if ord(key) = 8 then name3.Caption:=''
                else name3.Caption:=name3.Caption+key;
end;

procedure TForm1.Name4KeyPress(Sender: TObject; var Key: Char);
begin
if ord(key) = 8 then name4.Caption:=''
                else name4.Caption:=name4.Caption+key;
end;

procedure TForm1.Plus1Click(Sender: TObject);
begin
back_kolik:=1;
back_kde:=stisk;

if stisk=1 then body1.caption:=inttostr(strtoint(body1.caption)+back_kolik);
if stisk=2 then body2.caption:=inttostr(strtoint(body2.caption)+back_kolik);
if stisk=3 then body3.caption:=inttostr(strtoint(body3.caption)+back_kolik);
if stisk=4 then body4.caption:=inttostr(strtoint(body4.caption)+back_kolik);
end;

procedure TForm1.Plus2Click(Sender: TObject);
begin
back_kolik:=2;
back_kde:=stisk;

if stisk=1 then body1.caption:=inttostr(strtoint(body1.caption)+back_kolik);
if stisk=2 then body2.caption:=inttostr(strtoint(body2.caption)+back_kolik);
if stisk=3 then body3.caption:=inttostr(strtoint(body3.caption)+back_kolik);
if stisk=4 then body4.caption:=inttostr(strtoint(body4.caption)+back_kolik);
end;

procedure TForm1.Plus10Click(Sender: TObject);
begin
back_kolik:=10;
back_kde:=stisk;

if stisk=1 then body1.caption:=inttostr(strtoint(body1.caption)+back_kolik);
if stisk=2 then body2.caption:=inttostr(strtoint(body2.caption)+back_kolik);
if stisk=3 then body3.caption:=inttostr(strtoint(body3.caption)+back_kolik);
if stisk=4 then body4.caption:=inttostr(strtoint(body4.caption)+back_kolik);
end;

procedure TForm1.Plus20Click(Sender: TObject);
begin
back_kolik:=20;
back_kde:=stisk;

if stisk=1 then body1.caption:=inttostr(strtoint(body1.caption)+back_kolik);
if stisk=2 then body2.caption:=inttostr(strtoint(body2.caption)+back_kolik);
if stisk=3 then body3.caption:=inttostr(strtoint(body3.caption)+back_kolik);
if stisk=4 then body4.caption:=inttostr(strtoint(body4.caption)+back_kolik);
end;

procedure TForm1.ResetClick(Sender: TObject);
begin
body1.Caption:='0';
body2.Caption:='0';
body3.Caption:='0';
body4.Caption:='0';
back_kde:=0;

end;

procedure TForm1.BackClick(Sender: TObject);
begin
  case back_kde of
    1: Body1.caption:=inttostr(strtoint(Body1.caption)-back_kolik);
    2: Body2.caption:=inttostr(strtoint(Body2.caption)-back_kolik);
    3: Body3.caption:=inttostr(strtoint(Body3.caption)-back_kolik);
    4: Body4.caption:=inttostr(strtoint(Body4.caption)-back_kolik);
  end;
  back_kde:=0;
end;



begin
end.
