Beispiel #1
0
    {
        $this->radius = $r;
    }
    //get radius
    public function get_radius($r)
    {
        return $this->radius;
    }
}
$rect = new Rectangle();
$rect->set_height(5);
$rect->set_width(4);
$rect->calc_area();
echo "This object is a " . get_class($rect) . " and has an area of " . $rect->get_area();
echo "<br>";
$circ = new Circle();
$circ->set_radius(4);
$circ->calc_area();
echo "This object is a " . get_class($circ) . " and has an area of " . $circ->get_area();
echo "<br>";
$circ2 = new Circle();
$circ2->set_radius(6);
$circ2->calc_area();
echo "This object is a " . get_class($circ2) . " and has an area of " . $circ2->get_area();
echo "<br>";
echo "We now have " . Shape::$num_rect . " rectangles and " . Shape::$num_circ . " circles! <br>";
$circ2 = NULL;
echo "We now have " . Shape::$num_rect . " rectangles and " . Shape::$num_circ . " circles! <br>";
?>