//Demos the printShape function $shape->printShape(); //Rectangle $rec = new Rectangle(); $rec->__construct(4, 8, 20, 4, 2); $rec->printShape(); //Square $sq = new Square(); $sq->__construct(10, 40, 0, 5); $sq->printShape(); //Triangle $tri = new Triangle(); $tri->__construct(35, 20, 20, 50, 50, 50); $tri->printShape(); //Oval $oval = new Oval(); $oval->__construct(10, 9, 8); $oval->printShape(); //Circle $circle = new Circle(); $circle->__construct(80, 80, 10); $circle->printShape(); //Demos the getAreas function $shape->getAreas($shape, $rec, $circle); class Shape { /*Due to the nature of random shapes sideLengths does not go into the constructor. numSides will be calculated based on the number of sides entered.*/ public $sideLengths; public $numSides;
<?php /** * Created by PhpStorm. * User: ET * Date: 7/2/2015 * Time: 3:34 PM */ function __autoload($class) { include_once $class . '.php'; } $s = new Sphere(23); $o = new Oval(23, 11); $c = new Cylinder(22, 7); $circle = new Circle(12); echo '<p>Radius of the circle is: ' . $circle->getRadius() . '</p>'; echo '<p>Circumference of the Circle: ' . $circle->getCircumference() . '</p>'; echo '<p>Area of the Circle: ' . $circle->getArea() . '</p>'; echo '-------------------------------------------'; echo '<p>Height of the Cylinder: ' . $c->getHeight() . '</p>'; echo '<p>Radius of the Cylinder: ' . $c->getRadius() . '</p>'; echo '<p>Area of the Cylinder: ' . $c->getArea() . '</p>'; echo '-------------------------------------------'; echo '<p>Area of the Oval: ' . $o->getArea() . '</p>'; echo '<p>Length of Semi-Major Axis of the Oval: ' . $o->getRadius() . '</p>'; echo '<p>Length of Semi-Minor Axis of the Oval: ' . $o->getRadius2() . '</p>'; echo '-------------------------------------------'; echo '<p>Area of the Sphere: ' . $s->getArea() . '</p>'; echo '-------------------------------------------'; echo '<p>Total Circle related created: ' . Circle::getCounter() . '</p>';