Ejemplo n.º 1
0
    function perimeter()
    {
        return (2 * $this->radius * 3.14);
    }

    function translate($deltaX, $deltaY)
    {
        $this->centerx += $deltaX;
        $this->centery += $deltaY;
        return "X axis is now at " . ($this->centerx) . " and Y axis is now at " . ($this->centery);
    }

    function ptInCircle ($x, $y)
    {$dx = $this->centerx - $x;
     $dy = $this->centery - $y;

        if (pow($dx, 2) + pow($dy,2) < pow($this->radius,2)){
        return "true";
    }
        else return "false";}
}

$circle = new Circle(10,10,50);
echo $circle->area()."<br>";
echo $circle->perimeter()."<br>";
echo $circle->translate(15,15)."<br>";//will move x and y by 15
echo $circle->ptInCircle (11,11)."<br>";
echo $circle->ptInCircle(70,70)."<br>";
?>