}
    public function setSideLength($length)
    {
        $this->_sideLength = $length;
    }
    public function getArea()
    {
        return pow($this->_sideLength, 2);
    }
}
$myCircle = new Circle();
$myCircle->setColor("red");
$myCircle->fill();
$myCircle->setRadius(4);
echo "<h2>My Circle</h2>";
echo "<p>My circle has a radius of " . $myCircle->getRadius() . ".</p>";
echo "<p>It is " . $myCircle->getColor() . " and it is " . ($myCircle->isFilled() ? "filled" : "hollow") . ".</p>";
echo "<p>The area of my circle is: " . $myCircle->getArea() . ".</p>";
$mySquare = new Square();
$mySquare->setColor("green");
$mySquare->makeHollow();
$mySquare->setSideLength(3);
echo "<h2>My Square</h2>";
echo "<p>My square has a side length of " . $mySquare->getSideLength() . ".</p>";
echo "<p>It is " . $mySquare->getColor() . " and it is " . ($mySquare->isFilled() ? "filled" : "hollow") . ".</p>";
echo "<p>The area of my square is: " . $mySquare->getArea() . ".</p>";
?>

  </body>
</html>
예제 #2
0
 public function testHollow()
 {
     $circle = new Circle();
     $circle->makeHollow();
     $this->assertFalse($circle->isFilled());
 }