diff --git a/src/Circle.php b/src/Circle.php new file mode 100644 index 0000000..6a86639 --- /dev/null +++ b/src/Circle.php @@ -0,0 +1,26 @@ +radius = $radius; + $this->id = uniqid(); + } + + public function area() { + return M_PI * $this->radius * $this->radius; + } + + } // end class + +?> + diff --git a/src/Rectangle.php b/src/Rectangle.php new file mode 100644 index 0000000..1f47a23 --- /dev/null +++ b/src/Rectangle.php @@ -0,0 +1,11 @@ + + diff --git a/src/Shape.php b/src/Shape.php new file mode 100644 index 0000000..c3fe75b --- /dev/null +++ b/src/Shape.php @@ -0,0 +1,62 @@ +length = $length; + $this->width = $width; + $this->id = uniqid(); + } + + public function getName() { + return $this->name; + } + + public function setName( $name ) { + $this->name = $name; + } + + public function getId() { + return $this->id; + } + + public function area() { + return $this->length * $this->width; + } + + static public function getTypeDescription() { + return "Type: " . static::SHAPE_TYPE; + } + + public function getFullDescription() { + switch (static::SHAPE_TYPE) { + case 1: // case of SHAPE + $shapeName = "Shape"; + $postfix = "<#" . $this->id . ">: " . $this->name . " - " . $this->length . " x " . $this->width; + break; + case 2: // case of RECTANGLE + $shapeName = "Rectangle"; + $postfix = "<#" . $this->id . ">: " . $this->name . " - " . $this->length . " x " . $this->width; + break; + case 3: // case of CIRCLE + $shapeName = "Circle"; + $postfix = "<#" . $this->id . ">: " . $this->name . " - " . $this->radius; + break; + } // end switch + + return $shapeName . $postfix; + } + + } // end class + +?>