unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 =
class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn9: TBitBtn;
Label7: TLabel;
Label8: TLabel;
btWechsel: TButton;
lbWechsel: TLabel;
Label10: TLabel;
Label11: TLabel;
lbLiter: TLabel;
lbPreis: TLabel;
Label13: TLabel;
lblPreis1: TLabel;
TDauer: TTimer;
btTanken: TButton;
procedure btTankenClick(Sender: TObject);
procedure GroupBox1Click(Sender: TObject);
procedure GroupBox3Click(Sender: TObject);
procedure btWechselClick(Sender: TObject);
procedure TDauerTimer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
var Liter, lpreis, Preis : real;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btTankenClick(Sender: TObject);
begin
if btTanken.Caption ='
Tanken'
then
begin
btTanken.Caption:='
Stop';
TDauer.Enabled:=true;
end
else
begin
btTanken.Caption:='
Tanken';
TDauer.Enabled:=false;
lbPreis.Caption:=FloatToStr(liter*lpreis);
Label11.Visible:=true;
Label10.Visible:=true;
end;
end;
procedure TForm1.btWechselClick(Sender: TObject);
begin
if Preis<0
then
Preis:=0
else if Liter>0
then
Liter:=0
else if Preis>0
then
btWechsel.Enabled:=false
else if Preis>=0
then
btWechsel.Enabled:=false;
lbWechsel.Visible:=false;
lbLiter.Caption:=FloatToStr(Liter);
lbPreis.Caption:=FloatToStr(Preis);
GroupBox1.Enabled:=true;
Label10.Visible:=true;
Label11.Visible:=true;
end;
procedure TForm1.GroupBox1Click(Sender: TObject);
begin
if Sender=Button1
then
lPreis:=1.172
else if Sender=Button2
then
lPreis:=1.165
else if Sender=Button3
then
lPreis:=1.256
else if Sender=Button4
then
lPreis:=1.150;
GroupBox1.Enabled:=false;
GroupBox2.Enabled:=true;
lblpreis1.Caption:=FloatToStr(lpreis);
end;
procedure TForm1.GroupBox3Click(Sender: TObject);
begin
if Sender=BitBtn1
then
Preis:=Preis-0.1
else if Sender=BitBtn2
then
Preis:=Preis-0.2
else if Sender=BitBtn3
then
Preis:=Preis-0.5
else if Sender=BitBtn4
then
Preis:=Preis-1
else if Sender=BitBtn5
then
Preis:=Preis-2
else if Sender=BitBtn6
then
Preis:=Preis-5
else if Sender=BitBtn7
then
Preis:=Preis-10
else if Sender=BitBtn8
then
Preis:=Preis-20
else if Sender=BitBtn9
then
Preis:=Preis-50;
lbPreis.Caption:=FloatToStr(Preis);
Groupbox2.Enabled:=false;
end;
procedure TForm1.TDauerTimer(Sender: TObject);
begin
Liter:=Liter+1;
lbLiter.Caption:=FloatToStr(Liter);
Preis:=Liter*lpreis;
lbPreis.Caption:=FloatToStr(Liter*Preis);
end;
end.