unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
PaintBox1: TPaintBox;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Button2: TButton;
Button3: TButton;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Label4: TLabel;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
tgeo_objects =
class
end;
tpunkt =
class(tgeo_objects)
private
x,y:integer;
// HIER WIRD X UND Y DEKLARIERT AUF INTEGER NICHT RICHTIG OOP I KNOW
end;
TViereck =
class(Tpunkt)
public
procedure setx;
procedure sety;
function getx:integer;
function gety:integer;
protected
procedure zeichne;
end;
TDreieck =
class(Tpunkt)
protected
procedure zeichnen;
public
procedure setx;
procedure sety;
function getx:integer;
function gety:integer;
end;
TKreis =
class (TDreieck)
procedure Kreiszeichnen;
private
x1,y1,x2,y2:integer;
public
procedure setx1;
procedure sety1;
procedure setx2;
procedure sety2;
function getx1:integer;
function gety1:integer;
function getx2:integer;
function gety2:integer;
end;
Tgeo_objectsArray =
Array of Tgeo_objects;
var
Form1: TForm1;
lange,breite:integeR;
myviereck : Tviereck;
mydreieck : Tdreieck;
mykreis : Tkreis;
GeoArray :Tgeo_objectsarray;
implementation
procedure addtoarray(Geoobject:tgeo_objects);
begin
SetLength(GeoArray, Length(GeoArray) + 1);
GeoArray[High(GeoArray)] := GeoObject;
end;
procedure tviereck.setx;
//setzen
begin
x:= strtoint(form1.Edit1.text);
end;
procedure Tviereck.sety;
//setzen
begin
y:= strtoint(form1.edit2.Text);
end;
function Tviereck.getx;
begin
result :=x;
end;
function tviereck.gety;
begin
result:=y;
end;
procedure tdreieck.setx;
//setzen
begin
x:= strtoint(form1.Edit3.text);
end;
procedure Tdreieck.sety;
//setzen
begin
y:= strtoint(form1.edit4.Text);
end;
function Tdreieck.getx;
begin
result :=x;
end;
function tdreieck.gety;
begin
result:=y;
end;
procedure Tkreis.setx1;
begin
x1 := strtoint(form1.Edit5.Text);
end;
procedure Tkreis.sety1;
begin
y1 := strtoint(form1.edit6.text);
end;
procedure Tkreis.setx2;
begin
x2 := strtoint(form1.edit7.text);
end;
procedure Tkreis.sety2;
begin
y2:= strtoint(form1.Edit8.text);
end;
function tkreis.getx1;
begin
result := x1;
end;
function tkreis.gety1;
begin
result := y1;
end;
function tkreis.getx2;
begin
result := x2;
end;
function tkreis.gety2;
begin
result := y2;
end;
procedure TViereck.zeichne;
begin
form1.PaintBox1.Canvas.MoveTo(myviereck.getx,myviereck.gety);
form1.paintbox1.canvas.LineTo(myviereck.getx+100,myviereck.gety);
form1.paintbox1.canvas.lineto(myviereck.getx+100,myviereck.gety+100);
form1.paintbox1.canvas.lineto(myviereck.getx,myviereck.gety+100);
form1.paintbox1.Canvas.MoveTo(myviereck.getx,myviereck.gety);
form1.PaintBox1.canvas.LineTo(myviereck.getx,myviereck.gety+100);
end;
procedure Tdreieck.zeichnen;
begin
form1.PaintBox1.Canvas.MoveTo(mydreieck.getx,mydreieck.gety);
form1.PaintBox1.Canvas.LineTo(mydreieck.getx+100,mydreieck.gety);
form1.PaintBox1.Canvas.MoveTo(mydreieck.getx,mydreieck.gety);
form1.paintbox1.canvas.LineTo(mydreieck.getx,mydreieck.gety+100);
form1.paintbox1.Canvas.MoveTo(mydreieck.getx,mydreieck.gety+100);
form1.PaintBox1.Canvas.LineTo(mydreieck.getx+100,mydreieck.gety);
end;
procedure Tkreis.Kreiszeichnen;
begin
form1.PaintBox1.Canvas.Ellipse(x1,y1,x2,y2);
end;
procedure Farbe;
begin
if (form1.edit9.text) = ('
rot')
then
begin
form1.Color:=clred;
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Myviereck := Tviereck.creatE;
myviereck.setx;
myviereck.sety;
myviereck.zeichne;
myviereck.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mydreieck := tdreieck.Create;
mydreieck.setx;
mydreieck.sety;
mydreieck.zeichnen;
mydreieck.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
mykreis := tkreis.Create;
mykreis.setx1;
mykreis.sety1;
mykreis.setx2;
mykreis.sety2;
mykreis.Kreiszeichnen;
mykreis.Free;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
farbe;
end;
end.