Advertisement
daniv1

Untitled

Apr 11th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. unit KrugU;
  2.  
  3. interface
  4.  
  5. Uses PointU , SysUtils;
  6. Type Krug = class (Point)
  7. Protected
  8. Rad : real;
  9. public
  10. Constructor Create ( x ,y ,z , r : real) ;
  11. Procedure KoordFigur ( x , y , z , r : real);
  12. Procedure KoordRad ( r: real ) ;
  13. Function Print : string ; override ;
  14. function GetRad : real;
  15.  
  16. end;
  17.  
  18. implementation
  19.  
  20. procedure Krug.KoordRad;
  21. begin
  22. if r>=0 then rad:= r else rad := 0 ;
  23.  
  24. end;
  25.  
  26. Constructor Krug.Create(x: Real; y: Real; z: Real; r: Real);
  27. begin
  28. inherited Create(x,y,z);
  29. KoordRad(r);
  30. end;
  31.  
  32. procedure Krug.KoordFigur(x: Real; y: Real; z: Real; r: Real);
  33. begin
  34. KoordPoint(x,y,z);
  35. KoordRad(R);
  36.  
  37. end;
  38.  
  39.  
  40. function Krug.print;
  41. begin
  42. result := (inherited Print) + ' , Rad = ' + FloatToStr ( Rad) ;
  43.  
  44.  
  45. end;
  46.  
  47. Function Krug.GetRad;
  48. begin
  49. result := Rad;
  50. end;
  51.  
  52. end.
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. unit PointU;
  64.  
  65. interface
  66. Uses SysUtils;
  67. Type Point = class
  68. private
  69. x , y , z : real;
  70. public
  71. Constructor Create (x1 , y1 , z1 : real ) ;
  72. procedure KoordPoint ( x1 , y1 , z1 : real ) ;
  73. function print : string ; virtual;
  74. end;
  75. implementation
  76.  
  77. Constructor Point.Create(x1: Real; y1: Real; z1: Real);
  78. begin
  79.  
  80. KoordPoint(x1 , y1, z1);
  81. end;
  82.  
  83. procedure Point.KoordPoint(x1: Real; y1: Real; z1: Real);
  84. begin
  85. x := x1;
  86. y := y1;
  87. z := z1;
  88. end;
  89.  
  90. function Point.print;
  91. begin
  92. print:= 'koordinats : ( ' + FloatToStr(x) + ' ; ' + FloatToStr(y) + ' ; ' + FloatToStr(z) + ' ) ';
  93. end;
  94.  
  95. end.
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107. unit SphereU;
  108.  
  109. interface
  110.  
  111. Uses KrugU;
  112.  
  113. Type Sphere = Class ( Krug)
  114.  
  115. public
  116. Constructor Create ( x , y , z , r : real) ;
  117. Function Volume : real ;
  118. End;
  119. implementation
  120.  
  121. Constructor Sphere.Create(x: Real; y: Real; z: Real; r: Real);
  122. begin
  123. Inherited Create ( x , y, z ,r ) ;
  124. end;
  125.  
  126. Function Sphere.Volume;
  127. begin
  128. Result := 1.3333 * 3.1415 * rad * rad * rad;
  129. end;
  130.  
  131. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement