Circle.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: mrs
  5. * Date: 28.12.2017
  6. * Time: 10:33
  7. */
  8. require_once('AbstractCircle.php');
  9. class Circle extends CircleFigure
  10. {
  11. public $pointCenter;
  12. public $radius = 0;
  13. public $area = 0;
  14. public $circumference = 0;
  15. public function __construct(int $x1, int $y1, int $x2, int $y2, float $radius)
  16. {
  17. $this->x1 = $x1;
  18. $this->y1 = $y1;
  19. $this->x2 = $x2;
  20. $this->y2 = $y2;
  21. $this->radius = $radius;
  22. }
  23. public function getCoordinatesCenter(): array
  24. {
  25. return $this->pointCenter->coordinatesPoint;
  26. }
  27. public function printCoordinatesCenter(): void
  28. {
  29. echo "Координаты центра круга (x = " . $this->pointCenter->coordinatesPoint['x'] . ", y = " . $this->pointCenter->coordinatesPoint['y'];
  30. }
  31. public function getArea(): float
  32. {
  33. $area = round(M_PI * $this->radius ** 2, 2);
  34. return $this->area = $area;
  35. }
  36. public function printArea(): void
  37. {
  38. echo "Площадь круга равна " . $this->area;
  39. }
  40. public function getCircumference(): float
  41. {
  42. $circumference = round((2 * M_PI * $this->radius), 2);
  43. return $this->circumference = $circumference;
  44. }
  45. public function printCircumference(): void
  46. {
  47. echo "Длина окружности равна " . $this->circumference;
  48. }
  49. }