Добавил:
Upload
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
unit Unit2;
interface
uses Unit1,SysUtils, Dialogs;
type
TCone=class(TObject)
private
r1,r2,l,h:real;
{ Private declarations }
protected
{ Protected declarations }
public
function Get_Sb:real;
function Get_Sp:real;
function Get_So1:real;
function Get_So2:real;
procedure Resultshow;
constructor Set_init(a,b,c,d:Real);
{ Public declarations }
published
{ Published declarations }
end;
implementation
constructor TCone.Set_init(a,b,c,d:real);
begin
inherited Create;
if (a<0)or (b<0) or(c<0) or (d<0) then
begin
Showmessage('Ошибка!');
d:=0;
a:=0;
b:=0;
c:=0;
end
else
begin
r1:=a;
r2:=b;
l:=c;
h:=d;
Resultshow;
end;
end;
function TCone.Get_So2:real;
begin
Get_So2:=pi*r2*r2;
end;
function TCone.Get_So1:real;
begin
Get_So1:=pi*r1*r1;
end;
function TCone.Get_Sb:real;
begin
Get_Sb:=pi*l*(r2+r1);
end;
function TCone.Get_Sp:real;
begin
Get_Sp:=Get_So1+Get_So2+Get_Sb;
end;
procedure TCone.Resultshow;
begin
Form1.Label2.Caption:='Готово!';
Form1.SG2.Cells[1,0]:=floattostr(Get_So1);
Form1.SG2.Cells[1,1]:=floattostr(Get_So2);
Form1.SG2.Cells[1,2]:=floattostr(Get_Sb);
Form1.SG2.Cells[1,3]:=floattostr(Get_Sp);
end;
end.
interface
uses Unit1,SysUtils, Dialogs;
type
TCone=class(TObject)
private
r1,r2,l,h:real;
{ Private declarations }
protected
{ Protected declarations }
public
function Get_Sb:real;
function Get_Sp:real;
function Get_So1:real;
function Get_So2:real;
procedure Resultshow;
constructor Set_init(a,b,c,d:Real);
{ Public declarations }
published
{ Published declarations }
end;
implementation
constructor TCone.Set_init(a,b,c,d:real);
begin
inherited Create;
if (a<0)or (b<0) or(c<0) or (d<0) then
begin
Showmessage('Ошибка!');
d:=0;
a:=0;
b:=0;
c:=0;
end
else
begin
r1:=a;
r2:=b;
l:=c;
h:=d;
Resultshow;
end;
end;
function TCone.Get_So2:real;
begin
Get_So2:=pi*r2*r2;
end;
function TCone.Get_So1:real;
begin
Get_So1:=pi*r1*r1;
end;
function TCone.Get_Sb:real;
begin
Get_Sb:=pi*l*(r2+r1);
end;
function TCone.Get_Sp:real;
begin
Get_Sp:=Get_So1+Get_So2+Get_Sb;
end;
procedure TCone.Resultshow;
begin
Form1.Label2.Caption:='Готово!';
Form1.SG2.Cells[1,0]:=floattostr(Get_So1);
Form1.SG2.Cells[1,1]:=floattostr(Get_So2);
Form1.SG2.Cells[1,2]:=floattostr(Get_Sb);
Form1.SG2.Cells[1,3]:=floattostr(Get_Sp);
end;
end.