PHP: Utilisation d’une classe abstraite

Author:

 classe abstraite
Download

<?php
abstract class Personnel{
    function __construct($nom='Inconnue', $embauche='Inconnue', $salaire = 1500) {
        $this->nom = $nom;
        $this->embauche = $embauche;
        $this->salaire = $salaire;
    }
    function ModifierNom($nom) {
        $this->nom = $nom;
    }
    function ModifierEmbauche($embauche){
        $this->embauche = $embauche;
    }
    function ModifierSalaire($salaire) {
        $this->salaire = $salaire < 0 ? 0 : $salaire;
    }
    function getNom()
	 {
        return $this->nom;
    }
    function getEmbauche()
	 {
        return $this->embauche;
     }
	 function getSalaire()
	 {
        return $this->salaire;
     }
    abstract public function operationEmbauche(); 

} 

class Embauche extends Personnel
   {
    public function operationEmbauche()
	{
                printf("<p>Salarié:%s Date Embauche: *%s* Salaire: *%s*</p>", $this->getNom(), $this->getEmbauche(),
				 $this->getSalaire()); 

    }
}
 $test=new Embauche("Jhon Deer", "12/03/2000", 1250);
echo $test->operationEmbauche();
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


one × 6 =