浏览代码

inheritance classes of geometric shapes

bufon2211 6 年之前
父节点
当前提交
98837b6e9d
共有 1 个文件被更改,包括 62 次插入0 次删除
  1. 62 0
      Circle.php

+ 62 - 0
Circle.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: mrs
+ * Date: 28.12.2017
+ * Time: 10:33
+ */
+
+require_once('AbstractCircle.php');
+
+
+class Circle extends CircleFigure
+
+{
+    public $pointCenter;
+    public $radius = 0;
+    public $area = 0;
+    public $circumference = 0;
+
+    public function __construct(int $x1, int $y1, int $x2, int $y2, float $radius)
+    {
+        $this->x1 = $x1;
+        $this->y1 = $y1;
+        $this->x2 = $x2;
+        $this->y2 = $y2;
+        $this->radius = $radius;
+    }
+
+    public function getCoordinatesCenter(): array
+    {
+        return $this->pointCenter->coordinatesPoint;
+    }
+
+    public function printCoordinatesCenter(): void
+    {
+        echo "Координаты центра круга (x = " . $this->pointCenter->coordinatesPoint['x'] . ", y = " . $this->pointCenter->coordinatesPoint['y'];
+    }
+
+    public function getArea(): float
+    {
+        $area = round(M_PI * $this->radius ** 2, 2);
+        return $this->area = $area;
+    }
+
+    public function printArea(): void
+    {
+
+        echo "Площадь круга равна " . $this->area;
+    }
+
+    public function getCircumference(): float
+    {
+
+        $circumference = round((2 * M_PI * $this->radius), 2);
+        return $this->circumference = $circumference;
+    }
+
+    public function printCircumference(): void
+    {
+        echo "Длина окружности равна " . $this->circumference;
+    }
+}