Пример #1
0
//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;
    public $width;
    public $height;