Друзья попробывал создать класс, и нарисовать балку разного сечения 3 участка
что получилось естественно не компилирует, подскажите где ошибки
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
tuchastok=class
private
fdlina:real;
fploshad:real;
public
property dlina:real
read fdlina
write fdlina;
property ploshad:real
read fploshad
write fploshad;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
uchastok:array of tuchastok;
x:array of integer;
y:array of integer;
y_os:integer;
i, j:integer;
begin
x[0]:=100;
y[0]:=100;
for i:=1 to 3 do
begin
uchastok[i].dlina:=3*i;
uchastok[i].ploshad:=2*i;
end;
y_os:=y[0]+round((uchastok[1].ploshad*10)/2);
i:=1;
for j:=1 to 5 do
begin
if (j mod 2)>0
then
begin
x[j]:=round(uchastok[i].dlina*100);
x[j+1]:=round(uchastok[i].dlina*100);
i:=i+1;
end;
end;
i:=1;
for j:=1 to 5 do
begin
if j=1
then
begin
y[j]:=y_os+round((uchastok[i].ploshad*10)/2);
i:=i+1;
end
else
begin
if (j mod 2)=0
then
begin
y[j]:=y_os-round((uchastok[i].ploshad*10)/2);
y[j+1]:=y_os+round((uchastok[i].ploshad*10)/2);
i:=i+1;
end;
end;
end;
for i:=0 to 4 do
begin
form1.Canvas.Rectangle(x[i], y[i], x[i+1], y[i+1]);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
tuchastok.Create;
end;
end.
что интересует
правильно ли работаю с классом
почему не могу уничтожить данные которые хранит объект free и destroy не понимает