Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ООП / 2 / Unit2

.pas
Скачиваний:
47
Добавлен:
01.06.2015
Размер:
1 Кб
Скачать
☆
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.



Соседние файлы в папке 2
  • #
    01.06.201551 б46Unit1.ddp
  • #
    01.06.20152 Кб46Unit1.dfm
  • #
    01.06.20151 Кб46Unit1.pas
  • #
    01.06.20151 Кб47Unit2.~pas
  • #
    01.06.20153 Кб47Unit2.dcu
  • #
    01.06.20151 Кб47Unit2.pas