Code PHP :
<?php
interface Vehicule {
public function getColor();
}
interface Voiture extends Vehicule {
public function circulerEnVille();
}
interface Camion extends Vehicule {
public function attacherRemorque();
}
interface Moto extends Vehicule {
public function roulerSurRoueArriere();
}
class AmericanTruck implements Camion {
}
class Davidson implements Moto {
}
class Irma {
public function acheterVehicule(Vehicule $vehicule) {
if ($vehicule instanceof Camion)
echo "Okay I buy it";
else
echo "I'll only buy it for half its price";
}
}
Ce genre d'exemple est-il plus clair?