From 55a829fc03ba9e2213f6acdc88a257a3cdfe6563 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:36:09 -0500 Subject: [PATCH 01/12] Create Shape.php --- src/Shape.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Shape.php diff --git a/src/Shape.php b/src/Shape.php new file mode 100644 index 0000000..a2f5586 --- /dev/null +++ b/src/Shape.php @@ -0,0 +1,28 @@ +radius * $this->radius; + } + + public getFullDescription() { + return "Circle<#" . $this->id . ">: " . $this->name . " - " . $this->radius; + } + + } // end class + +?> From 7a1eba52c8b98d18ed35aba495c25f29e52da03f Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:36:41 -0500 Subject: [PATCH 02/12] Create Rectangle.php --- src/Rectangle.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Rectangle.php diff --git a/src/Rectangle.php b/src/Rectangle.php new file mode 100644 index 0000000..9046f97 --- /dev/null +++ b/src/Rectangle.php @@ -0,0 +1,12 @@ + From fc7048bbfe6ca0f83611f9de5b67fa67fdd115fc Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:37:25 -0500 Subject: [PATCH 03/12] Create Circle.php --- src/Circle.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Circle.php diff --git a/src/Circle.php b/src/Circle.php new file mode 100644 index 0000000..a2f5586 --- /dev/null +++ b/src/Circle.php @@ -0,0 +1,28 @@ +radius * $this->radius; + } + + public getFullDescription() { + return "Circle<#" . $this->id . ">: " . $this->name . " - " . $this->radius; + } + + } // end class + +?> From 1f6bd9547d80f8631fcc38f09381c8654ec725f6 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:38:28 -0500 Subject: [PATCH 04/12] Update Shape.php --- src/Shape.php | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/Shape.php b/src/Shape.php index a2f5586..6da09e6 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -1,27 +1,47 @@ 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 M_PI * $this->radius * $this->radius; + return $this->length * $this->width; } - - public getFullDescription() { - return "Circle<#" . $this->id . ">: " . $this->name . " - " . $this->radius; + + static public function getTypeDescription() { + return "Type: " . self::SHAPE_TYPE; } + + public function getFullDescription() { + return "Shape<#" . $this->id . ">: " . $this->name . " - " . $this->length . " x " . $this->width; + } + } // end class From 2fb0b00a526d618df141163de3667dc6a0a50449 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:43:23 -0500 Subject: [PATCH 05/12] Update Shape.php --- src/Shape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shape.php b/src/Shape.php index 6da09e6..3dafb6e 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -12,7 +12,7 @@ class Shape { private $id; // method declarations - void __construct ( $length = 0, $width = 0 ) { + __construct ( $length = 0, $width = 0 ) { $this->length = $length; $this->width = $width; $this->id = uniqid(); From 43c419f93aef722cb945c8673da9f32f7dae757b Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:48:24 -0500 Subject: [PATCH 06/12] Update Shape.php Fixed function keyword on constructor. --- src/Shape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shape.php b/src/Shape.php index 3dafb6e..bf7820a 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -12,7 +12,7 @@ class Shape { private $id; // method declarations - __construct ( $length = 0, $width = 0 ) { + function __construct ( $length = 0, $width = 0 ) { $this->length = $length; $this->width = $width; $this->id = uniqid(); From 46637918d7b36f55be87c9b09ab66a39d3294400 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 19:54:30 -0500 Subject: [PATCH 07/12] Update Circle.php Fixed function keyword in getFullDescription method. --- src/Circle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Circle.php b/src/Circle.php index a2f5586..e0b9aa4 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -19,7 +19,7 @@ public function area() { return M_PI * $this->radius * $this->radius; } - public getFullDescription() { + public function getFullDescription() { return "Circle<#" . $this->id . ">: " . $this->name . " - " . $this->radius; } From 2f566d99121a6a80ab2311cdce77924da3202036 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 20:03:26 -0500 Subject: [PATCH 08/12] Update Circle.php --- src/Circle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Circle.php b/src/Circle.php index e0b9aa4..ca40ca8 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -11,7 +11,7 @@ class Circle extends Shape { protected $radius; // method declarations - function __construct( $radius ) { + public function __construct( $radius ) { parent::__construct(); } From 1251293fd3ebb0d755c75f8ea07f4e80556a8594 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 20:04:10 -0500 Subject: [PATCH 09/12] Update Shape.php --- src/Shape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shape.php b/src/Shape.php index bf7820a..241610a 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -12,7 +12,7 @@ class Shape { private $id; // method declarations - function __construct ( $length = 0, $width = 0 ) { + public function __construct ( $length = 0, $width = 0 ) { $this->length = $length; $this->width = $width; $this->id = uniqid(); From c84002012845e8622325a0db8ea9416ebc7fc043 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 21:24:12 -0500 Subject: [PATCH 10/12] Update Circle.php --- src/Circle.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Circle.php b/src/Circle.php index ca40ca8..6a86639 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -1,28 +1,26 @@ radius = $radius; + $this->id = uniqid(); } public function area() { return M_PI * $this->radius * $this->radius; } - - public function getFullDescription() { - return "Circle<#" . $this->id . ">: " . $this->name . " - " . $this->radius; - } - + } // end class ?> + From 809d9e4bb1d3878b486cfdcd4ca1035b40f19e93 Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 21:24:42 -0500 Subject: [PATCH 11/12] Update Rectangle.php --- src/Rectangle.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Rectangle.php b/src/Rectangle.php index 9046f97..1f47a23 100644 --- a/src/Rectangle.php +++ b/src/Rectangle.php @@ -1,12 +1,11 @@ + From fee8a3c906a6ef22f7c2048de23d6c053d1ef2aa Mon Sep 17 00:00:00 2001 From: Calvin Miracle Date: Sat, 6 Feb 2016 21:25:26 -0500 Subject: [PATCH 12/12] Update Shape.php --- src/Shape.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Shape.php b/src/Shape.php index 241610a..c3fe75b 100644 --- a/src/Shape.php +++ b/src/Shape.php @@ -12,7 +12,7 @@ class Shape { private $id; // method declarations - public function __construct ( $length = 0, $width = 0 ) { + public function __construct ( $length = 0, $width = 0 ) { $this->length = $length; $this->width = $width; $this->id = uniqid(); @@ -35,14 +35,28 @@ public function area() { } static public function getTypeDescription() { - return "Type: " . self::SHAPE_TYPE; + return "Type: " . static::SHAPE_TYPE; } public function getFullDescription() { - return "Shape<#" . $this->id . ">: " . $this->name . " - " . $this->length . " x " . $this->width; + 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 ?>