1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <?php
class equation
{
private $a;
private $b;
private $c;
private $D;
private $x1;
private $x2;
private $x;
public function __construct()
{
$this->a = 1;
$this->b = -1;
$this->c = -1;
$this->D = (($this->b * $this->b)-(4 * $this->a * $this->c));
$this->x1 = ((-$this->b-sqrt($this->D))/(2 * $this->a));
$this->x2 = ((-$this->b+sqrt($this->D))/(2 * $this->a));
$this->x = ((-$this->b)/(2 * $this->a));
}
public function traitement()
{
if ($this->D > 0) {
echo "Il y a deus solution possible: X1 =".$this->x1." et X2 =".$this->x2."";
}
elseif ($this->D = 0) {
echo "Il y a une seule solution : X =".$this->x."";
}
else {
echo " Pas de solution";
}
}
}
$obj_solution = new equation();
echo "$obj_solution->traitement()";
?> |