Vous êtes sur la page 1sur 3

Class personne:

package ex2;

public class personne {

protected int id;


protected String nom;
protected String prenom;
protected String mail;
protected String telephone;
protected double salaire;

public personne(int id, String nom, String prenom, String


mail, String telephone, double salaire) {
this.id = id;
this.nom = nom;
this.prenom = prenom;
this.mail = mail;
this.telephone = telephone;
this.salaire = salaire;
}

public double calcul() {


return this.salaire;
}

public void affiche() {


System.out.print(nom +"\t"+prenom);
}
}

Class utilisateur :

package ex2;

public class utilisateur extends personne{


public String login;
public String password;
public String service;
public profil profil;

public utilisateur(int id, String nom, String prenom,


String mail, String telephone, double salaire, String login,
String password, String service, profil profil) {
super(id, nom, prenom, mail, telephone, salaire);
this.login = login;
this.password = password;
this.service = service;
this.profil = profil;
}

@Override
public double calcul() {
if (profil.getLibelle().equals("manager")) {
salaire = salaire + (salaire * 0.1);
}
if (profil.getLibelle().equals("directeur")) {
salaire = salaire + (salaire * 0.4);
}
return salaire;
}

@Override
public void affiche() {
super.affiche();
System.out.println(" est "+profil.getLibelle()+"
mon salaire est : " + this.calcul());
}
}

Class profil :

package ex2;

public class profil {

private int id;


private String code;
private String libelle;

public profil(String code, String libelle) {


this.code = code;
this.libelle = libelle;
}

public int getId() {


return id;
}

public void setId(int id) {


this.id = id;
}

public String getCode() {


return code;
}

public void setCode(String code) {


this.code = code;
}

public String getLibelle() {


return libelle;
}

public void setLibelle(String libelle) {


this.libelle = libelle;
}

Class test :

package ex2;

public class test {

public static void main(String[] args) {


profil p1 = new profil("a1", "manager");
profil p2 = new profil("a2", "directeur");
profil p3 = new profil("a2", "Chef de projet");
utilisateur u1 = new utilisateur(1, "eya", "hosni",
"eyahosni@gmail.com", "58749559", 1000.0, "EYA", "b",
"service1", p1);
utilisateur u2 = new utilisateur(2, "ayoub", "hosni",
"ayoubhosni@gmail.com", "58749559", 1000.0, "EYA", "b",
"service1", p2);
utilisateur u3 = new utilisateur(3, "farid", "hosni",
"faridhosni@gmail.com", "58749559", 1000.0, "EYA", "b",
"service1", p3);
u1.affiche();
u2.affiche();
u3.affiche();

}
}

Vous aimerez peut-être aussi