Ejemplo n.º 1
0
 function areaVerifier(Rectangle $r)
 {
     $r->setWidth(5);
     $r->setHeight(4);
     if ($r->area() != 20) {
         return false;
     }
     return true;
 }
        echo ", and its area is " . $this->_shape->getArea() . ".</p>";
    }
}
$myCircle = new Circle();
$myCircle->setColor("red");
$myCircle->fill();
$myCircle->setRadius(4);
$mySquare = new Square();
$mySquare->setColor("green");
$mySquare->makeHollow();
$mySquare->setSideLength(3);
$info = new ShapeInfo();
$info->setShape($myCircle);
$info->showInfo();
// Displays "The shape's color is red, and its area is 50.2654824574."
$info->setShape($mySquare);
$info->showInfo();
// Displays "The shape's color is green, and its area is 9."
$myRect = new Rectangle();
$myRect->setColor("yellow");
$myRect->fill();
$myRect->setWidth(4);
$myRect->setHeight(5);
$info->setShape($myRect);
$info->showInfo();
// Displays "The shape's color is yellow, and its area is 20."
?>

  </body>
</html>
Ejemplo n.º 3
0
 public function __construct($height)
 {
     parent::setHeight($height);
     parent::setWidth($height);
 }