Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Circle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
class Circle extends Shape {
const SHAPE_TYPE = 3;
protected $radius;

function __construct($circle_radius){
parent::__construct($length = null, $width = null);
$this->radius = $circle_radius;
}

function area (){
$circle_area = pi() * $this->radius * $this->radius;
return $circle_area;
}

public function getFullDescription (){
$string = "";
$string .= get_class($this)."<#";
$string .= $this->getId(). ">: ";
$string .= $this->getName(). " - ";
$string .= $this->radius;

return $string;
}
}
?>
5 changes: 5 additions & 0 deletions src/Rectangle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
class Rectangle extends Shape {
const SHAPE_TYPE = 2;
}
?>
48 changes: 48 additions & 0 deletions src/Shape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
class Shape {
const SHAPE_TYPE = 1;
public $name;
protected $length;
protected $width;
private $id;

function __construct($shape_length,$shape_width){
$this->length = $shape_length;
$this->width = $shape_width;
$this->id = uniqid();
}

function getName (){
return $this->name;
}

function setName($new_name){
$this->name = $new_name;
}

function getId() {
return $this->id;
}
function area (){
$shape_area = $this->length * $this->width;
return $shape_area;
}

static function getTypeDescription (){
return ("Type: ".static::SHAPE_TYPE);
}

public function getFullDescription (){
$string = "";
$string .= get_class($this)."<#";
$string .= $this->getId(). ">: ";
$string .= $this->getName(). " - ";
$string .= $this->length. " x ";
$string .= $this->width;

return $string;
}
}


?>