From 699b3e6f4e6e7413f34e0a4d6b72786bd76a975f Mon Sep 17 00:00:00 2001 From: Korey McMurtrey Date: Sun, 31 Jan 2016 13:27:13 -0500 Subject: [PATCH 1/6] Begins creation of Shape class --- instructions.md | 0 src/Circle.php | 0 src/Rectangle.php | 0 src/Shape.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 instructions.md create mode 100644 src/Circle.php create mode 100644 src/Rectangle.php create mode 100644 src/Shape.php diff --git a/instructions.md b/instructions.md new file mode 100644 index 0000000..e69de29 diff --git a/src/Circle.php b/src/Circle.php new file mode 100644 index 0000000..e69de29 diff --git a/src/Rectangle.php b/src/Rectangle.php new file mode 100644 index 0000000..e69de29 diff --git a/src/Shape.php b/src/Shape.php new file mode 100644 index 0000000..d0b5f99 --- /dev/null +++ b/src/Shape.php @@ -0,0 +1,46 @@ +length = $length; + $this->width = $width; + } + +/* +Getter and Setter methods for $name property +*/ + function getName() { + return $this->name; + } + + function setName($name) { + $this->name = $name; + return $name; + } + +/* +Getter method for $id property +*/ + function getId() { + return $this->id; + } + +/* +Area method to calculate and return the area of the Shape object +*/ + public function area($length, $width) { + $this->length = $length; + $this->width = $width; + + $area = $length x $width; + return $area; + } + +} From adc8324d44f593a39cff420223006ef63de15ab7 Mon Sep 17 00:00:00 2001 From: kmcmurtrey Date: Sun, 31 Jan 2016 19:58:08 -0500 Subject: [PATCH 2/6] Adds methods and properties for shape class --- src/Shape.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Shape.php b/src/Shape.php index d0b5f99..c1e0f59 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -38,9 +38,23 @@ function getId() { public function area($length, $width) { $this->length = $length; $this->width = $width; - + $area = $length x $width; return $area; } +/* +getTypeDexcription method to return the shape type +*/ + public static function getTypeDescription() { + return 'Type: ' . self::SHAPE_TYPE; + } + +/* +getFullDescription method to return string describing the shape +*/ + public getFullDescription() { + return 'Shape' . $this->id . ': ' . $this->name . ' - ' . $this->length . ' x ' . $this->width; + } + } From ed09eecb89ab0885724d85e2994bf2b2ae00a0b0 Mon Sep 17 00:00:00 2001 From: kmcmurtrey Date: Sun, 31 Jan 2016 20:00:13 -0500 Subject: [PATCH 3/6] Adds requirements for rectangle class --- src/Rectangle.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Rectangle.php b/src/Rectangle.php index e69de29..acdcc24 100644 --- a/src/Rectangle.php +++ b/src/Rectangle.php @@ -0,0 +1,7 @@ + Date: Sun, 31 Jan 2016 20:12:46 -0500 Subject: [PATCH 4/6] Adds requirements for circle class --- src/Circle.php | 31 +++++++++++++++++++++++++++++++ src/Shape.php | 5 +---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Circle.php b/src/Circle.php index e69de29..3a1fb78 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -0,0 +1,31 @@ +radius = $radius; + parent::__construct(); + } + +/* +area method to calculate and return the area of the circle (PI x r x r) +*/ + public function area() { + $pi = pi(); + $area = $pi x pow($radius, 2); + return $area; + } + +/* +getFullDescription method to return string describing the shape +*/ + public getFullDescription() { + return 'Circle' . $this->id . ': ' . $this->name . ' - ' . $this->radius; + } +} diff --git a/src/Shape.php b/src/Shape.php index c1e0f59..06eba1b 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -35,10 +35,7 @@ function getId() { /* Area method to calculate and return the area of the Shape object */ - public function area($length, $width) { - $this->length = $length; - $this->width = $width; - + public function area() { $area = $length x $width; return $area; } From 2418c69d10c54ea05ec9f6e05fb8f5de33cd1f9b Mon Sep 17 00:00:00 2001 From: kmcmurtrey Date: Sun, 31 Jan 2016 21:00:03 -0500 Subject: [PATCH 5/6] Only one error left --- src/Circle.php | 9 +++++---- src/Shape.php | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Circle.php b/src/Circle.php index 3a1fb78..a6cda19 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -9,8 +9,8 @@ class Circle extends Shape { Constructor accepts a radius parameter and intializes $radius. */ function __construct($radius) { + parent::__construct($length = null, $width = null); $this->radius = $radius; - parent::__construct(); } /* @@ -18,14 +18,15 @@ function __construct($radius) { */ public function area() { $pi = pi(); - $area = $pi x pow($radius, 2); + $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 getFullDescription() { - return 'Circle' . $this->id . ': ' . $this->name . ' - ' . $this->radius; + public function getFullDescription() { + return get_class($this) . '<#' . $this->getId() . '>: ' . $this->name . ' - ' . $this->radius; } } diff --git a/src/Shape.php b/src/Shape.php index 06eba1b..61fc051 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -36,22 +36,22 @@ function getId() { Area method to calculate and return the area of the Shape object */ public function area() { - $area = $length x $width; + $area = $this->length * $this->width; return $area; } /* -getTypeDexcription method to return the shape type +getTypeDescription method to return the shape type */ public static function getTypeDescription() { - return 'Type: ' . self::SHAPE_TYPE; + return 'Type: ' . static::SHAPE_TYPE; } /* getFullDescription method to return string describing the shape */ - public getFullDescription() { - return 'Shape' . $this->id . ': ' . $this->name . ' - ' . $this->length . ' x ' . $this->width; + public function getFullDescription() { + return get_class($this) . '<#' . $this->id . '>: ' . $this->name . ' - ' . $this->length . ' x ' . $this->width; } } From 107c1637a3c50eaa5e79c51491e9c0fc77e3d744 Mon Sep 17 00:00:00 2001 From: Korey McMurtrey Date: Thu, 4 Feb 2016 18:58:55 -0500 Subject: [PATCH 6/6] Sets the object $id in the constructor --- src/Shape.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Shape.php b/src/Shape.php index 61fc051..4b80271 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -11,6 +11,7 @@ class Shape { function __construct($length, $width) { $this->length = $length; $this->width = $width; + $this->id = uniqid(); } /*