Vous êtes sur la page 1sur 8

#include<iostream> #include<conio.

h>

using namespace std;

class personne { protected: char *Nom; char *Prenom; char *mail; public: personne(char *n,char *p,char *m) { Nom=new char [strlen(n)]; strcpy(Nom,n); Prenom=new char [strlen(p)]; strcpy(Prenom,p); mail=new char [strlen(m)]; strcpy(mail,m); } ~personne() { cout<<"La classe a t dtruite ! "<<endl; } void lecture() {

cout<<"Le nom de la personne est : "; cin>>Nom; cout<<endl; cout<<"Le prnom de la personne est "; cin>>Prenom; cout<<endl; cout<<"Le mail de la personne est "; cin>>mail; cout<<endl; } void affiche() { cout<<"- Le nom de la personne est : "<<Nom<<endl; cout<<"- Le prnom de la personne est "<<Prenom<<endl; cout<<"- Le mail de la personne est "<<mail<<endl; } };

class etudiant : public personne { protected : int promotion; float T_Notes[10]; float Moyenne; public : etudiant(char *n,char *p,char *m,int prom,float T[10]):personne(n,p,m) {

int i; promotion=prom; for(i=0;i<10;i++) { T_Notes[i]=T[i]; } } ~etudiant() { cout<<"la classe a ete detruite ! "<<endl; } float moyenne() { int i; float moy=0; for(i=0;i<10;i++) { moy=moy+T_Notes[i]; } Moyenne=moy/10; if(Moyenne>=12) return 1; else if((Moyenne<12) && (Moyenne>=8)) return 0; else return -1; } void affiche() { personne :: affiche();

int i; cout<<"--Promotion : "<<promotion<<endl; cout<<"--Tableau de notes :"<<endl; for(i=0;i<10;i++) { cout<<"--Note :"<<i<<"est :"<< T_Notes[i]<<endl; } } }; class employe : public personne { protected : float Salaire; public : employe(char *n,char *p,char *m,float sal):personne(n,p,m) { Salaire=sal; } ~employe() { cout<<"la classe a ete detruite ! "<<endl; } void affiche() { personne::affiche(); cout<<"--Le salaire : "<<Salaire<<endl; }

};

class enseignant : public employe { protected : char *Matiere; char *Departement; int Nbr_Heures; int Categorie; float Salaire; float Salaire_final; public: enseignant(char *n,char *p,char *m,float sal,char *Mat,char *Dept,int heures,int cat): employe(n,p,m,sal) { Matiere=new char [strlen(Mat)]; strcpy(Matiere,Mat); Departement=new char [strlen(Dept)]; strcpy(Departement,Dept); Nbr_Heures=heures; Categorie=cat; } ~enseignant() { cout<<"La classe a t dtruite ! "<<endl; } float salaire_final() {

int choix; float salaire_supplementaire; cout<<"Categorie 1 "<<"Nombre d'heures -- 280 "<<" Tarif TTC -- 220Dh "<<endl; cout<<"Categorie 2 "<<"Nombre d'heures -- 320 "<<" Tarif TTC -- 180Dh "<<endl; cout<<"Categorie 3 "<<"Nombre d'heures -- 380 "<<" Tarif TTC -- 150Dh "<<endl; cout<<"----------------------------------"<<endl; cout<<"faites votre choix :"<<endl; cin>>choix; cout<<"----------------------------------"<<endl; switch (choix) { case 1: { Nbr_Heures=280; salaire_supplementaire=280*220; }

break; case 2: { Nbr_Heures=320; salaire_supplementaire=320*180; } break; case 3: { Nbr_Heures=380;

salaire_supplementaire==380*150; } } Salaire_final=Salaire+salaire_supplementaire; return(Salaire_final); } void affiche() { employe::affiche(); cout<<"--La matiere "<<Matiere<<endl; cout<<"--Le departement "<<Departement<<endl; cout<<"--La Categorie "<<Categorie<<endl; cout<<"--Le salaire final "<<Salaire_final<<endl; } };

class administratif : public employe { protected: int Annee_recrutement; float Salaire_Adm; public : administratif(char *n,char *p,char *m,float sal,int annee,int sal_adm): employe(n,p,m,sal) { Annee_recrutement=annee; Salaire_Adm=sal_adm; }

~administratif() { cout<<"La classe a t dtruite ! "<<endl; } void anciennete() { int anc; anc=2012-Annee_recrutement; cout<<" Il travaille pendant "<<anc<<"ans"<<endl; } void affiche() { employe::affiche(); cout<<"--Annee de recrutement :"<<Annee_recrutement<<endl; cout<<"--Le salaire est : "<<Salaire_Adm<<endl; } };

main() {

getch(); }

Vous aimerez peut-être aussi