test test
test
[zeph] tayst
<?php
$voiture=new Voiture;
$voiture->Avance(15000);
class Voiture {
function __construct($marque="Peugeot") {
echo "Voiture créée : ".$marque."<br />";
$this->pneu_avd=new Pneu("Avant droit");
$this->pneu_avg=new Pneu("Avant gauche");
$this->pneu_ard=new Pneu("Arrière droit");
$this->pneu_arg=new Pneu("Arrière gauche");
}
function Avance($distance) {
for($i=1 ; $i<=$distance ; $i++) {
$this->pneu_avd->txgonflage*=0.99999;
$this->pneu_avg->txgonflage*=0.99999;
$this->pneu_ard->txgonflage*=0.99999;
$this->pneu_arg->txgonflage*=0.99999;
if($this->pneu_avd->txgonflage<=90) $this->pneu_avd->Regonfle();
if($this->pneu_avg->txgonflage<=90) $this->pneu_avg->Regonfle();
if($this->pneu_ard->txgonflage<=90) $this->pneu_ard->Regonfle();
if($this->pneu_arg->txgonflage<=90) $this->pneu_arg->Regonfle();
}
}
}
class Pneu {
function __construct($pneu) {
$this->pneu=$pneu;
$this->txgonflage=100;
echo "Pneu ".strtolower($pneu)." initialisé et gonflé à bloc<br />";
}
function Regonfle() {
echo "On regonfle un peu le pneu ".strtolower($this->pneu)." (".(int)$this->_EtatGonflagePneu()."% -> 100%) !<br />";
$this->txgonflage=100;
}
function _EtatGonflagePneu() {
return $this->txgonflage;
}
}
?>