-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathCircle.php
More file actions
32 lines (27 loc) · 800 Bytes
/
Circle.php
File metadata and controls
32 lines (27 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
class Circle extends Shape {
const SHAPE_TYPE = 3;
protected $radius;
/*
Constructor accepts a radius parameter and intializes $radius.
*/
function __construct($radius) {
parent::__construct($length = null, $width = null);
$this->radius = $radius;
}
/*
area method to calculate and return the area of the circle (PI x r x r)
*/
public function area() {
$pi = pi();
$area = $pi * pow($this->radius, 2);
return $area;
}
/*
getFullDescription method to return string describing the shape
Uses getId() to get the Id because that's a protected property of the parent class
*/
public function getFullDescription() {
return get_class($this) . '<#' . $this->getId() . '>: ' . $this->name . ' - ' . $this->radius;
}
}