unit uMain;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, logic,
Vcl.StdCtrls;
type
TForm1 =
class(TForm)
lbl1: TLabel;
btn1: TButton;
edt1: TEdit;
btn2: TButton;
edt2: TEdit;
lbl2: TLabel;
lbl3: TLabel;
btn3: TButton;
edt3: TEdit;
lbl4: TLabel;
lbl5: TLabel;
lbl6: TLabel;
lbl7: TLabel;
btn4: TButton;
lbl9: TLabel;
edt4: TEdit;
edt5: TEdit;
lbl10: TLabel;
lbl11: TLabel;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.btn2Click(Sender: TObject);
var MyFigure: TQuadrat;
begin
MyFigure:=TQuadrat.Create;
//Freigabe nicht erf., da TInterfacedObject dies übernimmt
try
MyFigure.SeiteA:=strtoint(edt1.Text);
MyFigure.SeiteB:=StrToInt(edt2.text);
lbl2.Caption:=FloatToStr(MyFigure.Umfangber);
lbl3.Caption:=FloatToStr(MyFigure.Flaechenber);
except
on E:
Exception do
begin
ShowMessage('
Exception class name = '+E.ClassName);
ShowMessage('
Exception message = '+E.
Message);
end;
end;
end;
procedure TForm1.btn3Click(Sender: TObject);
var MyFigure: TDreieck;
begin
MyFigure:=TDreieck.Create;
try
MyFigure.SeiteA:=StrToFloat(edt1.Text);
MyFigure.SeiteB:=StrToFloat(edt2.text);
MyFigure.SeiteC:=StrToFloat(edt4.text);
lbl2.Caption:=FloatToStr(MyFigure.Umfangber);
lbl3.Caption:=FloatToStr(MyFigure.Flaechenber);
except
on E:
Exception do
begin
ShowMessage('
Exception class name = '+E.ClassName);
ShowMessage('
Exception message = '+E.
Message);
end;
end;
end;
procedure TForm1.btn4Click(Sender: TObject);
var MyFigure: TTrapez;
begin
MyFigure:=TTrapez.Create;
try
MyFigure.SeiteA:=StrToFloat(edt1.Text);
MyFigure.SeiteB:=StrToFloat(edt2.text);
MyFigure.Hoehe:=StrToFloat(edt3.text);
MyFigure.SeiteC:=StrtoFloat(edt4.Text);
MyFigure.SeiteD:=StrtoFloat(edt5.Text);
lbl2.Caption:=FloatToStr(MyFigure.Umfangber);
lbl3.Caption:=FloatToStr(MyFigure.Flaechenber);
except
on E:
Exception do
begin
ShowMessage('
Exception class name = '+E.ClassName);
ShowMessage('
Exception message = '+E.
Message);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edt1.Clear;
edt2.Clear;
edt3.Clear;
edt4.Clear;
edt5.Clear;
lbl2.Caption:='
';
lbl3.Caption:='
';
end;
end.