Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Utilisation d’instance comme paramètre


{filelink=14120}

<?php
    class Employes {
        public $fonction;
        public $nom;
        public $prenom;
        public $montant;

        function __construct( $fonction, $prenom, $mainName, $montant ) {
            $this->fonction     = $fonction;
            $this->nom  = $mainName;
            $this->prenom = $prenom;
            $this->montant     = $montant;
        }

        function getNomComplet()
        {
            return "{$this->nom}" . " {$this->prenom}";
        }
    }

class PrimeEmploye
{
    public function primer( $employe )
    {
        $str  = "{$employe->fonction}: ";
        $str .= $employe->getNomComplet();
        $str .= " ({$employe->montant})";
        print $str;
    }
}
$employe1 = new Employes( "Agent marketing", "Dick", "Aflack", 1520 );
$promo = new PrimeEmploye();
$promo->primer( $employe1 );

?>

No comments yet.

Leave a Comment