You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
952 B

<?php
header('Content-Type: text/plain;charset=utf-8');
// récupérer ma librairie de formes
require(__dir__."/objets/formes.php");
echo "\n---------------";
// pour le polymorphisme
$tdf = array();
$tdf[0] = new cercle(9);
$tdf[1] = new triangle_rectangle(4,3);
$tdf[2] = new carre(2);
$tdf[3] = new rectangle(1,7);
$tdf[4] = "bonjour";
for($i=0;$i<5;$i++)
{
if($tdf[$i] instanceof forme)
{
echo "\n\n la forme ".$i." est de type : ";
echo $tdf[$i]->type();
echo "\n périmètre de la forme ".$i." : ";
echo $tdf[$i]->perimetre();
echo "\n surface de la forme ".$i." : ";
echo $tdf[$i]->surface();
}
if($tdf[$i] instanceof triangle_rectangle)
{
echo "\n hypothenuse de la forme ".$i." : ";
echo $tdf[$i]->hypothenuse();
}
}